Esempio n. 1
0
        public virtual IEnumerable <T> GetByIds <T>(IEnumerable <long> ids)
            where T : Entity
        {
            if (ids.Any())
            {
                // split into pages...
                var pages     = ids.SplitIntoPages(500);
                var unordered = (IList)this.EntityType.CreateCollectionInstance();
                foreach (var page in pages)
                {
                    var filter = new SqlFilter <T>();
                    filter.Constraints.AddValueListConstraint(this.EntityType.GetKeyFields()[0], page);

                    // put the retrieved reuslts back in the order we requested...
                    var toAdds = (IList)filter.ExecuteEnumerable();
                    foreach (var toAdd in toAdds)
                    {
                        unordered.Add(toAdd);
                    }
                }

                unordered.ReorderEntities(ids);
                return((IEnumerable <T>)unordered);
            }
            else
            {
                return(this.EntityType.CreateCollectionInstance <T>());
            }
        }