public MyQueryable <T> Include <TProperty>( Expression <Func <T, TProperty> > property, Expression <Func <TProperty, object> > fields) where TProperty : IEntity { if (property.Body.NodeType == ExpressionType.MemberAccess) { var visitor = new ObjectMemberVisitor(); visitor.Visit(property); var member = visitor.GetPropertyList().First(); visitor.Clear(); visitor.Visit(fields); var fieldList = visitor.GetPropertyList(); var prop = _includeProperties.SingleOrDefault(p => p.PropertyName == member); if (prop != null) { _includeProperties.Remove(prop); } _includeProperties.Add(new IncludeProperty(member, fieldList)); } return(this); }
public async Task <int> UpdateIgnoreAsync <T>(T entity, Expression <Func <T, object> > expression, bool ignoreAttribute = true) where T : IEntity { var entityInfo = MyEntityContainer.Get(typeof(T)); var visitor = new ObjectMemberVisitor(); visitor.Visit(expression); var include = visitor.GetPropertyList(); return(await UpdateIgnoreAsync(entity, include, ignoreAttribute)); }