/// <summary>
        /// Gets all <see cref="IPayment"/>.
        /// </summary>
        /// <param name="keys">
        /// The keys.
        /// </param>
        /// <returns>
        /// The <see cref="IEnumerable{IPayment}"/>.
        /// </returns>
        protected override IEnumerable <IPayment> PerformGetAll(params Guid[] keys)
        {
            var dtos = new List <PaymentDto>();

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

            var factory = new PaymentFactory();

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

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

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

            var factory = new PaymentFactory();

            var payment = factory.BuildEntity(dto);

            return(payment);
        }
示例#3
0
 /// <summary>
 /// Gets all <see cref="IPayment"/>.
 /// </summary>
 /// <param name="keys">
 /// The keys.
 /// </param>
 /// <returns>
 /// The <see cref="IEnumerable{IPayment}"/>.
 /// </returns>
 protected override IEnumerable <IPayment> PerformGetAll(params Guid[] keys)
 {
     if (keys.Any())
     {
         foreach (var id in keys)
         {
             yield return(Get(id));
         }
     }
     else
     {
         var factory = new PaymentFactory();
         var dtos    = Database.Fetch <PaymentDto>(GetBaseQuery(false));
         foreach (var dto in dtos)
         {
             yield return(factory.BuildEntity(dto));
         }
     }
 }