using System; using Shouldly; using Xunit; namespace PetaPoco.Tests.Integration.Databases.MSSQL { [Collection("Mssql")] public class MssqlQueryLinqTests : BaseQueryLinqTests { private readonly StorePerson _storePerson = new StorePerson { Id = Guid.NewGuid(), Age = 18, Name = "Peta" }; public MssqlQueryLinqTests() : base(new MssqlDBTestProvider()) { } [Fact] public void Exists_GivenPrimaryKeyMatchingOneRecordAndPocoWithSchema_ShouldBeTrue() { var pk = DB.Insert(_storePerson); DB.Exists(pk).ShouldBeTrue(); } [Fact] public void Exists_GivenSqlStringMatchingOneRecordAndPocoWithSchema_ShouldBeTrue() { DB.Insert(_storePerson); DB.Exists($"WHERE {DB.Provider.EscapeSqlIdentifier("Age")} = @0", 18).ShouldBeTrue(); } /// /// Support the older syntax of starting witha WHERE clause. /// [Fact] public void Exists_Regression_GivenSqlStringMatchingOneRecordAndPocoWithSchema_ShouldBeTrue() { DB.Insert(_storePerson); DB.Exists($"{DB.Provider.EscapeSqlIdentifier("Age")} = @0", 18).ShouldBeTrue(); } [TableName("store.People")] [PrimaryKey("Id", AutoIncrement = false)] public class StorePerson { [Column] public Guid Id { get; set; } [Column(Name = "FullName")] public string Name { get; set; } [Column] public long Age { get; set; } } } }