private static List<SpecialOfferEntity> FillMissingOffers(SpecialOfferEntity[] collectionToFill) { if (collectionToFill.Length > short.MaxValue) { throw new ArgumentException("The length of the collection (amount of special offers) must not exceed a short data type."); } for (int i = 0; i < collectionToFill.Length; i++) { SpecialOfferEntity placeholderSof = new SpecialOfferEntity(); placeholderSof.Number = (short) (i + 1); ProductEntity placeholderProduct = new ProductEntity(); placeholderProduct.Name = "Please Choose Product"; placeholderProduct.Id = -1; placeholderSof.Product = placeholderProduct; if (collectionToFill[i] == null) { collectionToFill[i] = placeholderSof; } } return new List<SpecialOfferEntity>(collectionToFill); }
public static List<SpecialOfferEntity> GetSpecialOffers(short numberToReturn) { EntityCollection offers = new EntityCollection(new SpecialOfferEntityFactory()); IPrefetchPath2 pf = new PrefetchPath2((int)EntityType.SpecialOfferEntity); pf.Add(SpecialOfferEntity.PrefetchPathProduct).SubPath.Add(ProductEntity.PrefetchPathProductSection); using (DataAccessAdapter adapter = new DataAccessAdapter()) { adapter.FetchEntityCollection(offers, null, numberToReturn, null, pf); } offers.SupportsSorting = true; offers.Sort((int) SpecialOfferFieldIndex.Number, ListSortDirection.Ascending); SpecialOfferEntity [] specialOffers = new SpecialOfferEntity[numberToReturn]; foreach (SpecialOfferEntity sof in offers) { specialOffers[sof.Number - 1] = sof; } return FillMissingOffers(specialOffers); }
/// <summary>Creates a new SpecialOfferEntity instance but uses a special constructor which will set the Fields object of the new /// IEntity2 instance to the passed in fields object. Implement this method to support multi-type in single table inheritance.</summary> /// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param> /// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns> public virtual IEntity2 Create(IEntityFields2 fields) { IEntity2 toReturn = new SpecialOfferEntity(fields); // __LLBLGENPRO_USER_CODE_REGION_START CreateNewSpecialOfferUsingFields // __LLBLGENPRO_USER_CODE_REGION_END return toReturn; }
/// <summary>Creates a new, empty SpecialOfferEntity object.</summary> /// <returns>A new, empty SpecialOfferEntity object.</returns> public virtual IEntity2 Create() { IEntity2 toReturn = new SpecialOfferEntity(); // __LLBLGENPRO_USER_CODE_REGION_START CreateNewSpecialOffer // __LLBLGENPRO_USER_CODE_REGION_END return toReturn; }