GetQueryText() public méthode

public GetQueryText ( Expression expression ) : string
expression System.Linq.Expressions.Expression
Résultat string
Exemple #1
0
            public void SelectWithBooleanTest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                SimpleDBQueryProvider queryProvider = new SimpleDBQueryProvider(null, null, null);
                Expression <Func <MockSIPAsset, bool> > whereClause = (asset) => asset.Expired;
                string querytext = queryProvider.GetQueryText(whereClause);

                Console.WriteLine("Query: " + querytext + ".");

                Assert.IsTrue(querytext == "expired = 'True'", "The query text was incorrect.");
            }
Exemple #2
0
            public void SelectWithLocallyScopedEmbeddedVariableOperatorTest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                SimpleDBQueryProvider queryProvider = new SimpleDBQueryProvider(null, null, null);
                Expression <Func <MockSIPAsset, bool> > whereClause = (asset) => asset.Inserted < DateTime.UtcNow;
                string querytext = queryProvider.GetQueryText(whereClause);

                Console.WriteLine("Query: " + querytext);

                Assert.IsTrue(Regex.Match(querytext, @"inserted < '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{7}Z'").Success, "The query text was incorrect.");
            }
Exemple #3
0
            public void SelectWithNotEqualMemberVariableOperatorTest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                SimpleDBQueryProvider queryProvider = new SimpleDBQueryProvider(null, null, null);
                var myObj = new { Name = "xyz" };
                Expression <Func <MockSIPAsset, bool> > whereClause = (asset) => asset.Username != myObj.Name;
                string querytext = queryProvider.GetQueryText(whereClause);

                Console.WriteLine("Query: " + querytext);

                Assert.IsTrue(querytext == "username != '" + myObj.Name + "'", "The query text was incorrect.");
            }
Exemple #4
0
            public void SelectWithNotCombinedWithAndOperatorTest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                SimpleDBQueryProvider queryProvider = new SimpleDBQueryProvider(null, null, null);
                DateTime checkDate = DateTime.Now;
                Expression <Func <MockSIPAsset, bool> > whereClause = (asset) => !asset.Expired && asset.Inserted >= checkDate;
                string querytext = queryProvider.GetQueryText(whereClause);

                Console.WriteLine("Query: " + querytext + ".");

                Assert.IsTrue(querytext == "not (expired = 'True') and inserted >= '" + checkDate.ToString("o") + "'", "The query text was incorrect.");
            }
Exemple #5
0
            public void SelectWithLocallyScopedVariableOperatorTest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                SimpleDBQueryProvider queryProvider = new SimpleDBQueryProvider(null, null, null);
                string username = "******";
                Expression <Func <MockSIPAsset, bool> > whereClause = (asset) => asset.Username == username;
                string querytext = queryProvider.GetQueryText(whereClause);

                Console.WriteLine("Query: " + querytext);

                Assert.IsTrue(querytext == "username = '******'", "The query text was incorrect.");
            }
Exemple #6
0
            public void SimpleSelectOnDateTest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                SimpleDBQueryProvider queryProvider = new SimpleDBQueryProvider(null, null, null);
                DateTime checkDate = DateTime.Now;
                Expression <Func <MockSIPAsset, bool> > whereClause = (asset) => asset.Inserted >= checkDate;
                string querytext = queryProvider.GetQueryText(whereClause);

                Console.WriteLine("Query: " + querytext);

                Assert.IsTrue(querytext == "inserted >= '" + checkDate.ToString("o") + "'", "The query text was incorrect.");
            }
Exemple #7
0
            public void SelectWithAndOperatorTest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                SimpleDBQueryProvider queryProvider = new SimpleDBQueryProvider(null, null, null);
                Guid id = Guid.NewGuid();
                Expression <Func <MockSIPAsset, bool> > whereClause = (asset) => asset.Id == id && asset.Username == "abcd";
                string querytext = queryProvider.GetQueryText(whereClause);

                Console.WriteLine("Query: " + querytext);

                Assert.IsTrue(querytext == "itemName() = '" + id + "' and username = '******'", "The query text was incorrect.");
            }
Exemple #8
0
            public void SimpleSelectOnIdTest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                SimpleDBQueryProvider queryProvider = new SimpleDBQueryProvider(null, null, null);
                Guid testGuid = Guid.NewGuid();
                Expression <Func <MockSIPAsset, bool> > whereClause = (asset) => asset.Id == testGuid;
                string querytext = queryProvider.GetQueryText(whereClause);

                Console.WriteLine("Query: " + querytext);

                Assert.IsTrue(querytext == "itemName() = '" + testGuid + "'", "The query text was incorrect.");
            }
            public void SelectWithLocallyScopedEmbeddedVariableOperatorTest() {

                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                SimpleDBQueryProvider queryProvider = new SimpleDBQueryProvider(null, null, null);
                Expression<Func<MockSIPAsset, bool>> whereClause = (asset) => asset.Inserted < DateTime.UtcNow;
                string querytext = queryProvider.GetQueryText(whereClause);
                Console.WriteLine("Query: " + querytext);

                Assert.IsTrue(Regex.Match(querytext, @"inserted < '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{7}Z'").Success, "The query text was incorrect.");
            }
            public void SelectWithNotEqualMemberVariableOperatorTest() {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                SimpleDBQueryProvider queryProvider = new SimpleDBQueryProvider(null, null, null);
                var myObj = new { Name = "xyz" };
                Expression<Func<MockSIPAsset, bool>> whereClause = (asset) => asset.Username != myObj.Name;
                string querytext = queryProvider.GetQueryText(whereClause);
                Console.WriteLine("Query: " + querytext);

                Assert.IsTrue(querytext == "username != '" + myObj.Name + "'", "The query text was incorrect.");
            }
            public void SelectWithMemberVariableCombinedWithAndClauseOperatorTest() {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                SimpleDBQueryProvider queryProvider = new SimpleDBQueryProvider(null, null, null);
                var myObj = new { Name = "xyz" };
                DateTime checkDate = DateTime.Now;
                Expression<Func<MockSIPAsset, bool>> whereClause = (asset) => asset.Username == myObj.Name && !asset.Expired && asset.Inserted >= checkDate;
                string querytext = queryProvider.GetQueryText(whereClause);
                Console.WriteLine("Query: " + querytext);

                Assert.IsTrue(querytext == "username = '******' and not (expired = 'True') and inserted >= '" + checkDate.ToString("o") + "'", "The query text was incorrect.");
            }
            public void SelectWithBooleanTest() {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                SimpleDBQueryProvider queryProvider = new SimpleDBQueryProvider(null, null, null);
                Expression<Func<MockSIPAsset, bool>> whereClause = (asset) => asset.Expired;
                string querytext = queryProvider.GetQueryText(whereClause);
                Console.WriteLine("Query: " + querytext + ".");

                Assert.IsTrue(querytext == "expired = 'True'", "The query text was incorrect.");
            }
            public void SelectWithLocallyScopedVariableOperatorTest() {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                SimpleDBQueryProvider queryProvider = new SimpleDBQueryProvider(null, null, null);
                string username = "******";
                Expression<Func<MockSIPAsset, bool>> whereClause = (asset) => asset.Username == username;
                string querytext = queryProvider.GetQueryText(whereClause);
                Console.WriteLine("Query: " + querytext);

                Assert.IsTrue(querytext == "username = '******'", "The query text was incorrect.");
            }
            public void SelectWithAndOperatorTest() {

                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                SimpleDBQueryProvider queryProvider = new SimpleDBQueryProvider(null, null, null);
                Guid id = Guid.NewGuid();
                Expression<Func<MockSIPAsset, bool>> whereClause = (asset) => asset.Id == id && asset.Username == "abcd";
                string querytext = queryProvider.GetQueryText(whereClause);
                Console.WriteLine("Query: " + querytext);

                Assert.IsTrue(querytext == "itemName() = '" + id + "' and username = '******'", "The query text was incorrect.");
            }
            public void SimpleSelectOnDateTest() {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                SimpleDBQueryProvider queryProvider = new SimpleDBQueryProvider(null, null, null);
                DateTime checkDate = DateTime.Now;
                Expression<Func<MockSIPAsset, bool>> whereClause = (asset) => asset.Inserted >= checkDate;
                string querytext = queryProvider.GetQueryText(whereClause);
                Console.WriteLine("Query: " + querytext);

                Assert.IsTrue(querytext == "inserted >= '" + checkDate.ToString("o") + "'", "The query text was incorrect.");
            }
            public void SimpleSelectOnIdTest() {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                SimpleDBQueryProvider queryProvider = new SimpleDBQueryProvider(null, null, null);
                Guid testGuid = Guid.NewGuid();
                Expression<Func<MockSIPAsset, bool>> whereClause = (asset) => asset.Id == testGuid;
                string querytext = queryProvider.GetQueryText(whereClause);
                Console.WriteLine("Query: " + querytext);

                Assert.IsTrue(querytext == "itemName() = '" + testGuid + "'", "The query text was incorrect.");
            }