Пример #1
0
        /// <summary>
        /// Gets a collection of all <see cref="IShipRateTier"/>.
        /// </summary>
        /// <param name="keys">
        /// The keys.
        /// </param>
        /// <returns>
        /// The <see cref="IEnumerable{IShipRateTier}"/>.
        /// </returns>
        protected override IEnumerable <IShipRateTier> PerformGetAll(params Guid[] keys)
        {
            var dtos = new List <ShipRateTierDto>();

            if (keys.Any())
            {
                // This is to get around the WhereIn max limit of 2100 parameters and to help with performance of each WhereIn query
                var keyLists = keys.Split(400).ToList();

                // Loop the split keys and get them
                foreach (var keyList in keyLists)
                {
                    dtos.AddRange(Database.Fetch <ShipRateTierDto>(GetBaseQuery(false).WhereIn <ShipRateTierDto>(x => x.Key, keyList, SqlSyntax)));
                }
            }
            else
            {
                dtos = Database.Fetch <ShipRateTierDto>(GetBaseQuery(false));
            }

            var factory = new ShipRateTierFactory();

            foreach (var dto in dtos)
            {
                yield return(factory.BuildEntity(dto));
            }
        }
Пример #2
0
        protected override IShipRateTier PerformGet(Guid key)
        {
            var sql = GetBaseQuery(false)
                      .Where(GetBaseWhereClause(), new { Key = key });

            var dto = Database.Fetch <ShipRateTierDto>(sql).FirstOrDefault();

            if (dto == null)
            {
                return(null);
            }

            var factory = new ShipRateTierFactory();

            return(factory.BuildEntity(dto));
        }
Пример #3
0
 protected override IEnumerable <IShipRateTier> PerformGetAll(params Guid[] keys)
 {
     if (keys.Any())
     {
         foreach (var key in keys)
         {
             yield return(Get(key));
         }
     }
     else
     {
         var factory = new ShipRateTierFactory();
         var dtos    = Database.Fetch <ShipRateTierDto>(GetBaseQuery(false));
         foreach (var dto in dtos)
         {
             yield return(factory.BuildEntity(dto));
         }
     }
 }