protected void AttachInnerEntities(EntityInterface model) { var dbSets = QueryableExtensions.GetEntityTypes(_dataContext); var res = model.GetType() .GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance) .Join( dbSets, y => y.PropertyType, x => x, (propInfo, gerericArg) => propInfo); foreach (System.Reflection.PropertyInfo p in res) { _dataContext.Set(p.PropertyType).Attach(p.GetValue(model)); } }
public IQueryable <EntityInterface> GetEntities(System.Linq.Expressions.Expression <Func <EntityInterface, bool> > predicate) { ValidateDataContext(); return(_dataContext.Set <EntityModel>().Where(predicate) .IncludeReferences(typeof(EntityModel), null, QueryableExtensions.GetEntityTypes(_dataContext), true)); }