///<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); }
///<include file='docs.xml' path='doc/members/member[@name="M:GenericRepositoryAndService.Tools.Generic.GenericToolsQueriesAndLists.ListRemoveElementWithGivenKeys``1(System.Collections.Generic.List{``0},System.Object[])"]/*'/> public static List <T> ListRemoveElementWithGivenKeys <T>(List <T> req, params object[] objs) { GenericToolsTypeAnalysis.CheckIfObjectIsKey <T>(objs); Func <T, bool> func; if (typeof(BaseEntity).IsAssignableFrom(typeof(T))) { int id = (int)objs[0]; func = GenericToolsExpressionTrees.ExpressionListRemoveElementWithGivenId <T>(id).Compile(); } else { func = GenericToolsExpressionTrees.ExpressionListRemoveElementWithGivenKeys <T>(objs).Compile(); } return(req.Where(func).ToList()); }