public void GetRoleFunctionList(string personId) { //子查询 Base_Person_FunctionInfo personFun = new Base_Person_FunctionInfo() { PersonId = personId, DirectionFlag = -1 }; OQLChildFunc oqlChild = parent => OQL.From(parent, personFun) .Select(true, personFun.FunctionId) .Where(personFun.PersonId, personFun.DirectionFlag) .END; //查询所有功能,并从中过滤掉子查询的结果 Base_FunctionInfo fun = new Base_FunctionInfo(); Base_Person_RoleInfo personRole = new Base_Person_RoleInfo() { PersonId = personId }; Base_Role_FunctionInfo roleFun = new Base_Role_FunctionInfo(); OQL oql = OQL.From(personRole) .InnerJoin(roleFun).On(personRole.RoleId, roleFun.RoleId) .InnerJoin(fun).On(roleFun.FunctionId, fun.FunctionId) .Select(true, fun.FunctionId, fun.FunctionName, fun.NavigateAddress) .Where(cmp => cmp.EqualValue(personRole.PersonId) & cmp.Comparer(fun.FunctionId, OQLCompare.CompareType.NotIn, oqlChild)) .END; //return EntityQuery<Base_FunctionInfo>.QueryList(oql); Console.WriteLine("OQL Test Child Query:\r\n{0}\r\n", oql); Console.WriteLine(oql.PrintParameterInfo()); }
void TestChild2() { /* * SELECT * FROM [LT_Users] WHERE RoleID = * (SELECT ID FROM dbo.LT_UserRoles r WHERE [LT_Users].NickName=r.NickName) */ Users user = new Users() { NickName = "_nickName" }; UserRoles roles = new UserRoles() { NickName = "_roleNickName" }; OQLChildFunc childFunc = parent => OQL.From(parent, roles) .Select(roles.ID) .Where(cmp => cmp.Comparer(user.NickName, "=", roles.NickName) //比较的字段顺序无所谓 & cmp.Property(roles.AddTime) > DateTime.Now.AddDays(-3)) .END; OQL q = OQL.From(user) .Select() .Where(cmp => cmp.Comparer(user.RoleID, "=", childFunc)) .END; q.SelectStar = true; Console.WriteLine("OQL by 高级子查询Test:\r\n{0}", q); Console.WriteLine(q.PrintParameterInfo()); }
public OQLCompare Comparer(object field, string typeString, OQLChildFunc Value) { OQL childOql = Value(this.LinkedOQL); return(Comparer(field, CompareString2Type(typeString), childOql)); }
public OQLCompare Comparer(object field, CompareType type, OQLChildFunc Value) { OQL childOql = Value(this.LinkedOQL); return(Comparer(field, type, childOql)); }