예제 #1
0
        public ResultSerialData GetMultipleItems(IEnumerable <Dto> partialDtos, string[] expand)
        {
            var resultSerialData = new ResultSerialData()
            {
                Items          = null,
                EntityTypeName = this.entityTypeName,
                TotalCount     = 0,
                RelatedItems   = { }
            };
            var derivedEntity = default(T);

            if (this.dataContext.entitySets.ContainsKey(this.entityTypeName))
            {
                var dtos      = new List <Dto>();
                var entitySet = (EntitySet <T>) this.dataContext.entitySets[this.entityTypeName];
                foreach (var partialDto in partialDtos)
                {
                    derivedEntity = entitySet.FindByKey(partialDto);
                    if (derivedEntity != null)
                    {
                        dtos.Add(derivedEntity.entity.dto);
                    }
                }
                resultSerialData.Items = dtos;
                DataViewLocalDtoUtils.FillResultRelatedItems(this.entityTypeName, resultSerialData, expand, this.dataContext, this.metadataSrv);
            }
            return(resultSerialData);
        }
예제 #2
0
        public ResultSingleSerialData GetSingleItem1(Dto partialDto, string[] expand)
        {
            var resultSingleSerialData = new ResultSingleSerialData()
            {
                Item           = null,
                EntityTypeName = this.entityTypeName,
                RelatedItems   = { }
            };

            if (this.dataContext.entitySets.ContainsKey(this.entityTypeName))
            {
                var entitySet     = (EntitySet <T>) this.dataContext.entitySets[this.entityTypeName];
                var derivedEntity = entitySet.FindByKey(partialDto /*partialEntity*/);
                resultSingleSerialData.Item = derivedEntity.entity.dto;
                DataViewLocalDtoUtils.FillResultSingleRelatedItems(this.entityTypeName, resultSingleSerialData, expand, this.dataContext, this.metadataSrv);
            }
            return(resultSingleSerialData);
        }
예제 #3
0
        public ResultSerialData GetItems(Func <T, bool> predicate, string[] expand)
        {
            var resultSerialData = new ResultSerialData()
            {
                Items          = { },
                EntityTypeName = this.entityTypeName,
                TotalCount     = 0,
                RelatedItems   = { }
            };

            if (this.dataContext.entitySets.ContainsKey(this.entityTypeName))
            {
                var entitySet         = (EntitySet <T>) this.dataContext.entitySets[this.entityTypeName];
                var derivedEntityList = entitySet.Filter(predicate);
                resultSerialData.Items = derivedEntityList.Select((it) => it.entity.dto).ToList();
                DataViewLocalDtoUtils.FillResultRelatedItems(this.entityTypeName, resultSerialData, expand, this.dataContext, this.metadataSrv);
            }
            return(resultSerialData);
        }