示例#1
0
        public IReadOnlyList <AttributeHolder> Get([NotNull] EntityMetadata entityMetadata, long rowstamp, SearchRequestDto searchDto = null)
        {
            if (entityMetadata == null)
            {
                throw new ArgumentNullException("entityMetadata");
            }
            if (searchDto == null)
            {
                searchDto = new SearchRequestDto();
            }
            var query = new EntityQueryBuilder().AllRows(entityMetadata, searchDto);

            if (searchDto.QueryGeneratorService != null && entityMetadata is SlicedEntityMetadata)
            {
                var sliced      = (SlicedEntityMetadata)entityMetadata;
                var customQuery = GenericSwMethodInvoker.Invoke <string>(sliced.AppSchema, searchDto.QueryGeneratorService, entityMetadata,
                                                                         searchDto);
                if (customQuery != null)
                {
                    query.Sql = customQuery;
                }
            }

            var rows = Query(entityMetadata, query, rowstamp, searchDto);

            return(rows.Cast <IEnumerable <KeyValuePair <string, object> > >()
                   .Select(r => BuildDataMap(entityMetadata, r))
                   .ToList());
        }
示例#2
0
        public int Count([NotNull] EntityMetadata entityMetadata, [NotNull] SearchRequestDto searchDto)
        {
            if (entityMetadata == null)
            {
                throw new ArgumentNullException("entityMetadata");
            }
            if (searchDto == null)
            {
                throw new ArgumentNullException("searchDto");
            }
            var query = new EntityQueryBuilder().CountRows(entityMetadata, searchDto);

            if (searchDto.QueryGeneratorService != null && entityMetadata is SlicedEntityMetadata)
            {
                var sliced = (SlicedEntityMetadata)entityMetadata;

                var customQuery = GenericSwMethodInvoker.Invoke <string>(sliced.AppSchema, searchDto.QueryGeneratorService + "Count", entityMetadata,
                                                                         searchDto);
                if (customQuery != null)
                {
                    query.Sql = customQuery;
                }
            }

            return(GetDao(entityMetadata).CountByNativeQuery(query.Sql, query.Parameters, searchDto.QueryAlias));
        }