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

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

            var factory = new InvoiceStatusFactory();

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

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

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

            var factory = new InvoiceStatusFactory();

            var invoiceStatus = factory.BuildEntity(dto);

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