示例#1
0
            internal ICollection <T> Get <T>(EntityFilter filter) where T : Entity
            {
                // The returned entity type is determined by
                // 1) the filter passed in or 2) the type of T if there is no filter.
                var targetEntityType = filter != null ? filter.EntityType : typeof(T);
                var type             = ResolveAssetType(targetEntityType);
                var query            = new Query(type);

                if (filter != null)
                {
                    var defaultToken = GetDefaultOrderByToken(targetEntityType);
                    IAttributeDefinition defaultOrderBy = null;

                    if (defaultToken != null)
                    {
                        defaultOrderBy = instance.MetaModel.GetAttributeDefinition(defaultToken);
                    }

                    query.Filter    = filter.BuildFilter(type, instance);
                    query.Find      = filter.BuildFind(type);
                    query.OrderBy   = filter.BuildOrderBy(type, defaultOrderBy);
                    query.Selection = filter.BuildSelection(type);
                }

                return(instance.QueryToEntityEnum <T>(query));
            }