Ejemplo n.º 1
0
 public void Test2()
 {
     DbEntry.From <Article>().Where(p => p.Title.StartsWith("tom")).Select();
     AssertSql("SELECT [Id],[Title],[User_Id] AS [User] FROM [Article] WHERE [Title] LIKE @Title_0;\n<Text><60>(@Title_0=tom%:String)");
 }
Ejemplo n.º 2
0
        public void TestNotIn()
        {
            DbEntry.From <SinglePersonSqlite>().Where(CK.K["Id"].NotIn(1, 3, 5, 7)).Select();
            AssertSql(@"SELECT [Id],[Name] FROM [People] WHERE [Id] NOT IN (@in_0,@in_1,@in_2,@in_3);
<Text><60>(@in_0=1:Int32,@in_1=3:Int32,@in_2=5:Int32,@in_3=7:Int32)");
        }
Ejemplo n.º 3
0
 public void Test1()
 {
     var list = DbEntry.From<JoinClass>().Where(Condition.Empty).Select();
     Assert.IsNotNull(list);
     Assert.AreEqual(0, list.Count);
 }
Ejemplo n.º 4
0
 public void Test3()
 {
     Assert.AreEqual(3, DbEntry.From <Category>().Where(Condition.Empty).GetCount());
     Assert.AreEqual(5, DbEntry.From <Book>().Where(Condition.Empty).GetCount());
     Assert.AreEqual(2, DbEntry.From <Book>().Where(CK.K["Category_Id"] == 3).GetCount());
 }
Ejemplo n.º 5
0
        public void TestUpperForLike()
        {
            DbEntry.From <SinglePersonSqlite>().Where(CK.K["Name"].ToUpper().Like("%tom%")).Select();
            AssertSql(@"SELECT [Id],[Name] FROM [People] WHERE UPPER([Name]) LIKE @Name_0;
<Text><60>(@Name_0=%tom%:String)");
        }
Ejemplo n.º 6
0
 public void TestGroupBy()
 {
     DbEntry.From <SoftDeleteSqlite>().Where(Condition.Empty).GroupBy <string>("tom");
     Assert.AreEqual("SELECT [tom],COUNT([tom]) AS it__count__ FROM [SoftDelete] WHERE [IsDeleted] = @IsDeleted_0 GROUP BY [tom];\n<Text><60>(@IsDeleted_0=False:Boolean)", StaticRecorder.LastMessage);
 }
Ejemplo n.º 7
0
 public void TestJoinTableNoCreate()
 {
     DbEntry.From <JoinTableNoCreate>().Where(Condition.Empty).Select();
 }
Ejemplo n.º 8
0
 public void Test6()
 {
     DbEntry.From <PersonSqlite>().Where(Condition.Empty).OrderByDescending(p => p.FirstName).ThenBy(p => p.Id).Select();
     Assert.AreEqual("SELECT [Id],[Name] AS [FirstName] FROM [People] ORDER BY [Name] DESC,[Id] ASC;\n<Text><60>()", StaticRecorder.LastMessage);
 }
Ejemplo n.º 9
0
        public void TestLowerFunction()
        {
            DbEntry.From <PersonSqlite>().Where(p => p.FirstName.ToLower() == "tom").Select();
            AssertSql(@"SELECT [Id],[Name] AS [FirstName] FROM [People] WHERE LOWER([Name]) = @Name_0;
<Text><60>(@Name_0=tom:String)");
        }
Ejemplo n.º 10
0
 public void TestNotNull()
 {
     StaticRecorder.ClearMessages();
     DbEntry.From <PropertyClassWithDbColumnSql>().Where(CK.K["Name"] != null).Select();
     Assert.AreEqual("SELECT [Id],[Name] AS [TheName] FROM [People] WHERE [Name] IS NOT NULL;\n<Text><60>()", StaticRecorder.LastMessage);
 }
Ejemplo n.º 11
0
 public void Test3()
 {
     DbEntry.From <PersonSqlite>()
     .Where(p => p.FirstName.Contains("T")).Select();
     Assert.AreEqual("SELECT [Id],[Name] AS [FirstName] FROM [People] WHERE [Name] LIKE @Name_0;\n<Text><60>(@Name_0=%T%:String)", StaticRecorder.LastMessage);
 }
Ejemplo n.º 12
0
 public void Test2NdPageWithSqlserver2005WithAlias()
 {
     StaticRecorder.ClearMessages();
     DbEntry.From <FieldPersonSql>().Where(CK.K["Age"] > 18).OrderBy("Id").Range(3, 5).Select();
     Assert.AreEqual("SELECT [Id],[TheName] FROM (SELECT [Id],[Name] AS [TheName], ROW_NUMBER() OVER ( ORDER BY [Id] ASC) AS __rownumber__ FROM [People]  WHERE [Age] > @Age_0) AS T WHERE T.__rownumber__ >= 3 AND T.__rownumber__ <= 5 ORDER BY T.__rownumber__;\n<Text><60>(@Age_0=18:Int32)", StaticRecorder.LastMessage);
 }
Ejemplo n.º 13
0
 public void TestSelect()
 {
     DbEntry.From <PeopleModel2>().Where(CK.K["Name"] == "tom" && CK.K["Age"] > 18).Select();
     Assert.AreEqual("SELECT \"ID\",\"NAME\" FROM \"PEOPLE\" WHERE (\"NAME\" = @Name_0) AND (\"AGE\" > @Age_1);<Text><60>(@Name_0=tom:String,@Age_1=18:Int32)", StaticRecorder.LastMessage);
 }
Ejemplo n.º 14
0
 public void Test3()
 {
     DbEntry.From <Article>().Where(p => p.Title.ToLower() == "tom").Select();
     AssertSql("SELECT [Id],[Title],[User_Id] AS [User] FROM [Article] WHERE LOWER([Title]) = @Title_0;\n<Text><60>(@Title_0=tom:String)");
 }
Ejemplo n.º 15
0
        public void TestDelete1()
        {
            DbEntry.From <TestClass>().Where(p => p.Name == "abc").Delete();
            AssertSql(@"DELETE FROM [Test_Class] WHERE [Name] = @Name_0;
<Text><30>(@Name_0=abc:String)");
        }
Ejemplo n.º 16
0
        public void TestUpperForLike()
        {
            DbEntry.From <PersonSqlite>().Where(p => p.FirstName.ToUpper().Contains("tom")).Select();
            AssertSql(@"SELECT [Id],[Name] AS [FirstName] FROM [People] WHERE UPPER([Name]) LIKE @Name_0;
<Text><60>(@Name_0=%tom%:String)");
        }
Ejemplo n.º 17
0
        public void TestCount()
        {
            long n = DbEntry.From <SoftDelete>().Where(Condition.Empty).GetCount();

            Assert.AreEqual(3, n);
        }
Ejemplo n.º 18
0
 public void TestEnum()
 {
     DbEntry.From <EnumTest>().Where(p => p.Abc == MyEnum.Test1).Select();
     AssertSql("SELECT [Id],[ccc] AS [Abc] FROM [Enum_Test] WHERE [ccc] = @ccc_0;\n<Text><60>(@ccc_0=0:Int32)");
 }
Ejemplo n.º 19
0
 public List <T> Find(Expression <Func <T, bool> > condition)
 {
     return(DbEntry.From <T>().Where(condition).OrderBy(_order).Select());
 }
Ejemplo n.º 20
0
 public void TestBoolOfDefault()
 {
     DbEntry.From <BoolTest>().Where(p => p.Available).Select();
     AssertSql("SELECT [Id],[Name],[Available] FROM [Bool_Test] WHERE [Available] = @Available_0;\n<Text><60>(@Available_0=True:Boolean)");
 }
Ejemplo n.º 21
0
        public void TestPartOf()
        {
            DbEntry.From <DtPart>().Where(Condition.Empty).Select();
            AssertSql(@"SELECT [Id],[dtValue] FROM [DateAndTime];
<Text><60>()");
        }
Ejemplo n.º 22
0
 public void TestBoolOfDefault2()
 {
     DbEntry.From <BoolTest>().Where(p => p.Available && p.Name == "tom").Select();
     AssertSql("SELECT [Id],[Name],[Available] FROM [Bool_Test] WHERE ([Available] = @Available_0) AND ([Name] = @Name_1);\n<Text><60>(@Available_0=True:Boolean,@Name_1=tom:String)");
 }
Ejemplo n.º 23
0
        public void TestUpperFunction()
        {
            DbEntry.From <SinglePersonSqlite>().Where(CK.K["Name"].ToUpper() == "tom").Select();
            AssertSql(@"SELECT [Id],[Name] FROM [People] WHERE UPPER([Name]) = @Name_0;
<Text><60>(@Name_0=tom:String)");
        }
Ejemplo n.º 24
0
 public void TestInClause()
 {
     DbEntry.From <BoolTest>().Where(p => p.Id.In(1, 3, 5, 7)).Select();
     AssertSql("SELECT [Id],[Name],[Available] FROM [Bool_Test] WHERE [Id] IN (@in_0,@in_1,@in_2,@in_3);\n<Text><60>(@in_0=1:Int64,@in_1=3:Int64,@in_2=5:Int64,@in_3=7:Int64)");
 }
Ejemplo n.º 25
0
        public void TestInSql()
        {
            DbEntry.From <SinglePersonSqlite>().Where(CK.K["Id"].InSql("Select Id From Others")).Select();
            AssertSql(@"SELECT [Id],[Name] FROM [People] WHERE [Id] IN (Select Id From Others);
<Text><60>()");
        }
Ejemplo n.º 26
0
 public void TestNotIn2()
 {
     DbEntry.From <BoolTest>().Where(CK.K["Id"].NotIn(1, 3, 5, 7)).Select();
     AssertSql("SELECT [Id],[Name],[Available] FROM [Bool_Test] WHERE [Id] NOT IN (@in_0,@in_1,@in_2,@in_3);\n<Text><60>(@in_0=1:Int32,@in_1=3:Int32,@in_2=5:Int32,@in_3=7:Int32)");
 }
Ejemplo n.º 27
0
        public void TestNotIn2()
        {
            DbEntry.From <SinglePersonSqlite>().Where(CK.K["Name"].NotIn("Tom", "Jerry")).Select();
            AssertSql(@"SELECT [Id],[Name] FROM [People] WHERE [Name] NOT IN (@in_0,@in_1);
<Text><60>(@in_0=Tom:String,@in_1=Jerry:String)");
        }
Ejemplo n.º 28
0
 public void TestNotIn3()
 {
     DbEntry.From <BoolTest>().Where(CK.K["Name"].NotIn("Tom", "Jerry")).Select();
     AssertSql("SELECT [Id],[Name],[Available] FROM [Bool_Test] WHERE [Name] NOT IN (@in_0,@in_1);\n<Text><60>(@in_0=Tom:String,@in_1=Jerry:String)");
 }
Ejemplo n.º 29
0
 public void TestLazyLoadFieldForCondition2()
 {
     DbEntry.From <lzpUserSqlite>().Where(p => p.Profile == "test").Select();
     AssertSql("SELECT [Id],[Name] FROM [lzp_User_Sqlite] WHERE [Profile] = @Profile_0;\n<Text><60>(@Profile_0=test:String)");
 }
Ejemplo n.º 30
0
 public void Test1()
 {
     DbEntry.From <Article>().Where(p => p.User.Value.Id.In(1)).Select();
     AssertSql("SELECT [Id],[Title],[User_Id] AS [User] FROM [Article] WHERE [User_Id] IN (@in_0);\n<Text><60>(@in_0=1:Int64)");
 }