示例#1
0
        /// <summary>
        /// Gets all <see cref="IShipCountry"/>.
        /// </summary>
        /// <param name="keys">
        /// The keys.
        /// </param>
        /// <returns>
        /// The <see cref="IEnumerable{IShipCountry}"/>.
        /// </returns>
        protected override IEnumerable <IShipCountry> PerformGetAll(params Guid[] keys)
        {
            var dtos = new List <ShipCountryDto>();

            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 <ShipCountryDto>(GetBaseQuery(false).WhereIn <ShipCountryDto>(x => x.Key, keyList, SqlSyntax)));
                }
            }
            else
            {
                dtos = Database.Fetch <ShipCountryDto>(GetBaseQuery(false));
            }

            var factory = new ShipCountryFactory(_storeSettingService);

            foreach (var dto in dtos)
            {
                yield return(factory.BuildEntity(dto));
            }
        }
        /// <summary>
        /// Gets a <see cref="IShipCountry"/> by it's key.
        /// </summary>
        /// <param name="key">
        /// The key.
        /// </param>
        /// <returns>
        /// The <see cref="IShipCountry"/>.
        /// </returns>
        protected override IShipCountry PerformGet(Guid key)
        {
            var sql = GetBaseQuery(false)
                      .Where(GetBaseWhereClause(), new { Key = key });

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

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

            var factory = new ShipCountryFactory(_storeSettingService);

            return(factory.BuildEntity(dto));
        }
 /// <summary>
 /// Gets all <see cref="IShipCountry"/>.
 /// </summary>
 /// <param name="keys">
 /// The keys.
 /// </param>
 /// <returns>
 /// The <see cref="IEnumerable{IShipCountry}"/>.
 /// </returns>
 protected override IEnumerable <IShipCountry> PerformGetAll(params Guid[] keys)
 {
     if (keys.Any())
     {
         foreach (var key in keys)
         {
             yield return(Get(key));
         }
     }
     else
     {
         var factory = new ShipCountryFactory(_storeSettingService);
         var dtos    = Database.Fetch <ShipCountryDto>(GetBaseQuery(false));
         foreach (var dto in dtos)
         {
             yield return(factory.BuildEntity(dto));
         }
     }
 }