Beispiel #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 void PersistNewItem(IInvoiceStatus entity)
        {
            ((Entity)entity).AddingEntity();

            var factory = new InvoiceStatusFactory();
            var dto     = factory.BuildDto(entity);

            Database.Insert(dto);
            entity.Key = dto.Key;
            entity.ResetDirtyProperties();
        }
        protected override void PersistUpdatedItem(IInvoiceStatus entity)
        {
            ((Entity)entity).UpdatingEntity();

            var factory = new InvoiceStatusFactory();
            var dto     = factory.BuildDto(entity);

            Database.Update(dto);

            entity.ResetDirtyProperties();
        }
        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));
         }
     }
 }