public static GuidFilter Merge(GuidFilter parameter1, GuidFilter parameter2) { if (parameter1 == null) { parameter1 = new GuidFilter(); } if (parameter2 != null) { if (parameter2.Equal != null) { parameter1.Equal = parameter2.Equal; } if (parameter2.NotEqual != null) { parameter1.NotEqual = parameter2.NotEqual; } if (parameter2.In != null) { if (parameter1.In == null) { parameter1.In = parameter2.In; } else { parameter1.In.AddRange(parameter2.In); } } if (parameter2.NotIn != null) { if (parameter1.NotIn == null) { parameter1.NotIn = parameter2.NotIn; } else { parameter1.NotIn.AddRange(parameter2.NotIn); } } } return(parameter1); }
public static IQueryable <TSource> Where <TSource, TKey>(this IQueryable <TSource> source, Expression <Func <TSource, TKey> > propertyName, GuidFilter filter) { if (filter.Equal.HasValue) { source = source.Where(BuildPredicate(propertyName, "==", filter.Equal.Value.ToString())); } if (filter.NotEqual.HasValue) { source = source.Where(BuildPredicate(propertyName, "!=", filter.NotEqual.Value.ToString())); } if (filter.In != null) { source = source.Where(BuildPredicate(propertyName, "In", filter.In)); } if (filter.NotIn != null) { source = source.Where(BuildPredicate(propertyName, "NotIn", filter.In)); } return(source); }