///<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.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.ListWherePropNotNull``1(System.Collections.Generic.List{``0},System.String)"]/*'/> public static List <T> ListWherePropNotNull <T>(List <T> lst, string propname) { lst = lst.Where( GenericToolsExpressionTrees.PropertyKeysNotNull <T>(typeof(T).GetProperty(propname)).Compile() ).ToList(); return(lst); }
///<include file='docs.xml' path='doc/members/member[@name="M:GenericRepositoryAndService.Tools.Generic.GenericToolsQueriesAndLists.ListWhereOtherTypePropListNotContains``2(System.Collections.Generic.List{``1},``0,System.String,System.Int32)"]/*'/> public static List <Q> ListWhereOtherTypePropListNotContains <T, Q>(List <Q> req, T newitem, string tpropname, int nbr = 1) { Func <Q, bool> func = GenericToolsExpressionTrees.ExpressionListWhereOtherTypePropListNotContains <T, Q>(newitem, tpropname, nbr).Compile(); var tempreq = req.Where(func); if (tempreq.Count() == 0) { return(new List <Q>()); } else { return(tempreq.ToList()); } //req.Where( q => !newitem.tpropname.Where(qq => qq.Id == q.Id).Count() == 1 ) }
///<include file='docs.xml' path='doc/members/member[@name="M:GenericRepositoryAndService.Tools.Generic.GenericToolsQueriesAndLists.ListWherePropListCountainsOnlyElementWithGivenKeys``2(System.Collections.Generic.List{``1},System.Type,System.String,System.Object[])"]/*'/> public static List <Q> ListWherePropListCountainsOnlyElementWithGivenKeys <T, Q>(List <Q> req, Type q, string propname, params object[] objs) { Func <Q, bool> func = GenericToolsExpressionTrees.ExpressionListWherePropListCountainsOnlyElementWithGivenKeys <T, Q>(q.GetProperty(propname), objs).Compile(); var tempreq = req.Where(func); if (tempreq.Count() == 0) { return(new List <Q>()); } else { return(tempreq.ToList()); } //req.Where( t => t.propname.Where(...).Count()==1) }
///<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()); }
///<include file='docs.xml' path='doc/members/member[@name="M:GenericRepositoryAndService.Tools.Generic.GenericToolsQueriesAndLists.ListWhereKeysAreCountSup1``1(System.Collections.Generic.IList{``0},System.Object[])"]/*'/> public static bool ListWhereKeysAreCountSup1 <T>(IList <T> req, params object[] objs) { Func <T, bool> func = GenericToolsExpressionTrees.ExpressionWhereKeysAre <T>(objs).Compile(); return(req.Where(func).Count() >= 1); }