private static FormattedSql ParseWhere(string filter) { var repo = RF.ResolveInstance <TestUserRepository>(); var q = Parse(filter, repo); return(QueryNodeTester.GenerateTestSql(q.Where)); }
public void ODT_Filter_Enum_Label_WithQuote() { var repo = RF.ResolveInstance <TestRoleRepository>(); var q = Parse("RoleType ne '管理员'", repo); var sql = QueryNodeTester.GenerateTestSql(q.Where); Assert.IsTrue(sql.ToString() == @"Roles.RoleType != {0}"); }
public void ODT_Filter_Enum_Nullable() { var repo = RF.ResolveInstance <TestRoleRepository>(); var q = Parse("RoleType2 ne Administrator", repo); var sql = QueryNodeTester.GenerateTestSql(q.Where); Assert.IsTrue(sql.ToString() == @"Roles.RoleType2 != {0}"); }
public void ODT_Filter_Enum_Name_WithBracket() { var repo = RF.ResolveInstance <TestRoleRepository>(); var q = Parse("(RoleType ne Administrator or RoleType ne Normal)", repo); var sql = QueryNodeTester.GenerateTestSql(q.Where); Assert.IsTrue(sql.ToString() == @"Roles.RoleType != {0} OR Roles.RoleType != {1}", "枚举值后紧跟括号时,需要能解析出枚举的值。"); }
public void ODT_Filter_Enum_Label() { var repo = RF.ResolveInstance <TestRoleRepository>(); var q = Parse("RoleType ne 管理员", repo); var sql = QueryNodeTester.GenerateTestSql(q.Where); AssertSqlEqual(sql.ToString(), @"Roles.RoleType != {0}"); }
public void ODT_Filter_EnumValue_WithQuote() { var repo = RF.Concrete <TestRoleRepository>(); var q = Parse("RoleType ne 'Administrator'", repo); var sql = QueryNodeTester.GenerateTestSql(q.Where); Assert.IsTrue(sql.ToString() == @"Roles.RoleType != {0}"); }
public void ODT_Filter_Enum_Label() { var repo = RF.Concrete <TestRoleRepository>(); var q = Parse("RoleType ne 管理员", repo); var sql = QueryNodeTester.GenerateTestSql(q.Where); Assert.IsTrue(sql.ToString() == @"Roles.RoleType != {0}"); }
private static FormattedSql Parse(string filter) { var repo = RF.Concrete <TestUserRepository>(); var f = QueryFactory.Instance; var t = f.Table(repo); var parser = new ODataFilterParser { _mainTable = t, _properties = repo.EntityMeta.ManagedProperties.GetCompiledProperties() }; var constraint = parser.Parse(filter); return(QueryNodeTester.GenerateTestSql(constraint)); }
private static FormattedSql ParseFull(string filter, IRepository repo) { var q = Parse(filter, repo); return(QueryNodeTester.GenerateTestSql(q)); }