///<include file='docs.xml' path='doc/members/member[@name="M:GenericRepositoryAndService.Tools.Generic.GenericToolsQueriesAndLists.QueryWhereKeysAre``1(System.Linq.IQueryable{``0},System.Object[])"]/*'/> public static IQueryable <T> QueryWhereKeysAre <T>(IQueryable <T> req, params object[] objs) { GenericToolsTypeAnalysis.CheckIfObjectIsKey <T>(objs); if (typeof(T).IsSubclassOf(typeof(BaseEntity))) { int?id = GenericToolsTypeAnalysis.ObjectsToId <T>(objs); req = req.Where( GenericToolsExpressionTrees.PropertyEquals <T>( typeof(T).GetProperty("Id"), id ) ); } else { int i = 0; foreach (object obj in objs) { req = req.Where( GenericToolsExpressionTrees.PropertyEquals <T>( typeof(T).GetProperty(GenericToolsTypeAnalysis.KeyPropertiesNames <T>()[i]), obj ) ); i++; } } return(req); }
///<include file='docs.xml' path='doc/members/member[@name="M:GenericRepositoryAndService.Tools.Generic.GenericToolsQueriesAndLists.ListWherePropKeysAre``2(System.Collections.Generic.List{``1},System.String,System.Object[])"]/*'/> private static List <Q> ListWherePropKeysAre <T, Q>(List <Q> req, string propname, object[] objs) { GenericToolsTypeAnalysis.CheckIfObjectIsKey <T>(objs); if (typeof(T).IsSubclassOf(typeof(BaseEntity))) { int?id = GenericToolsTypeAnalysis.ObjectsToId <T>(objs); req = req.Where( GenericToolsExpressionTrees.ExpressionPropPropEquals <Q>( typeof(Q).GetProperty(propname), typeof(T).GetProperty("Id"), id ).Compile() ).ToList(); } else { int i = 0; foreach (object obj in objs) { req = req.Where( GenericToolsExpressionTrees.ExpressionPropPropEquals <Q>( typeof(Q).GetProperty(propname), typeof(T).GetProperty(GenericToolsTypeAnalysis.KeyPropertiesNames <T>()[i]), obj ).Compile() ).ToList(); i++; } } return(req); }