public override PostProjectionLoadedResult GetResult(IUnprojectedBinding binding, List <object> resultSet) { var result = new PostProjectionLoadedResult(); result.ProjectionBinding = binding; var m2mRelationship = GetManyToManyRelationship(binding as UnprojectedManyToManyBinding); Func <AnonymousType, object> valueGetter = ao => Get_GetProjectedValue_Computation(binding.TargetBinding)(new TableEntityRow(ao)); var query = GetQuery(resultSet, valueGetter, m2mRelationship.MapType); var includes = ModifyExpressions(GetIncludes(binding) , m2mRelationship.RelatedEntitySelectorFromMap.Body as MemberExpression); //loading both ends of the map object includes.AddRange(new[] { m2mRelationship.RelatedEntitySelectorFromMap, m2mRelationship.SelfSelectorFromMap }); query = LoadIncludes(query, m2mRelationship.MapType, includes); result.Value = MethodFinder.EnumerableMethods.ToList(m2mRelationship.MapType).Invoke(null, new object[] { query }) as IList; return(result); }
protected List <LambdaExpression> GetIncludes(IUnprojectedBinding binding) { return(projectedType.UnprojectedBindings .Where(b => b is UnprojectedIncludeInCollectionBinding && b.TargetBinding == binding) .Select(b => ((b as UnprojectedIncludeInCollectionBinding).IncludeDirective as IIncludeInCollectionDirective) .GetFieldSelector()).ToList()); }
public override PostProjectionLoadedResult GetResult(IUnprojectedBinding binding, List <object> objects) { var result = new PostProjectionLoadedResult(); result.ProjectionBinding = binding; var targetType = TypesUtil.GetGenericArgumentForBaseType(binding.TargetBinding.Type, typeof(IEnumerable <>)); Func <AnonymousType, object> valueGetter = ao => Get_GetProjectedValue_Computation(binding.TargetBinding)(new TableEntityRow(ao)); var query = GetQuery(objects, valueGetter, targetType); query = LoadIncludes(query, targetType, GetIncludes(binding)); result.Value = MethodFinder.EnumerableMethods.ToList(targetType).Invoke(null, new object[] { query }) as IList; return(result); }
private Func <object, TableEntityRow, object> Get_GetUnprojectedCollections_Computation(IUnprojectedBinding binding, List <PostProjectionLoadedResult> postProjectionResults) { var list = postProjectionResults.Find(r => r.ProjectionBinding == binding).Value.Cast <IEntity>().ToList(); return((projectedEntity, source) => { var items = new List <object>(); foreach (var projectedItem in (projectedEntity as IEnumerable)) { var item = list.Find(entity => entity._getIntermediateEntity()._getTableEntity().Equals(projectedItem)); if (item != null) { items.Add(item); } else { throw new ApplicationException("Data Inconsistency while loading Collection."); } } return items; }); }
public abstract PostProjectionLoadedResult GetResult(IUnprojectedBinding binding, List <object> objects);