Esempio n. 1
0
        /// <summary>
        /// Gets the collection of all <see cref="ITaxMethod"/>.
        /// </summary>
        /// <param name="keys">
        /// The keys.
        /// </param>
        /// <returns>
        /// The <see cref="IEnumerable{ITaxMethod}"/>.
        /// </returns>
        protected override IEnumerable <ITaxMethod> PerformGetAll(params Guid[] keys)
        {
            var dtos = new List <TaxMethodDto>();

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

            var factory = new TaxMethodFactory();

            foreach (var dto in dtos)
            {
                yield return(factory.BuildEntity(dto));
            }
        }
        protected override ITaxMethod PerformGet(Guid key)
        {
            var sql = GetBaseQuery(false)
                      .Where(GetBaseWhereClause(), new { Key = key });

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

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

            var factory = new TaxMethodFactory();

            return(factory.BuildEntity(dto));
        }
 protected override IEnumerable <ITaxMethod> PerformGetAll(params Guid[] keys)
 {
     if (keys.Any())
     {
         foreach (var key in keys)
         {
             yield return(Get(key));
         }
     }
     else
     {
         var factory = new TaxMethodFactory();
         var dtos    = Database.Fetch <TaxMethodDto>(GetBaseQuery(false));
         foreach (var dto in dtos)
         {
             yield return(factory.BuildEntity(dto));
         }
     }
 }