private void CreateProducts(IList <CompositeKeyEntity> compositeKeyEntities, IList <TypeIdIncludedEntity> typeIdIncludedEntities) { var nameIndex = 0; var items = compositeKeyEntities.Zip(typeIdIncludedEntities, (c, t) => new { CompositeKeyEntity = c, TypeIdIncludedEntity = t }); foreach (var item in items) { var product = new Product { Name = nameIndex.ToString("D2"), CreationDate = DateTime.UtcNow, UIndentifier = Guid.NewGuid(), CompositeKeyRef = item.CompositeKeyEntity, TypeIdIncludedRef = item.TypeIdIncludedEntity }; productToComositeKeyMap.Add(product.Key, item.CompositeKeyEntity.Key); productToIncludedTypeKeyMap.Add(product.Key, item.TypeIdIncludedEntity.Key); nameIndex++; } foreach (var item in items.Reverse()) { var dProduct = new DerivedProduct { Name = nameIndex.ToString("D2"), CreationDate = DateTime.UtcNow, UIndentifier = Guid.NewGuid(), CompositeKeyRef = item.CompositeKeyEntity, TypeIdIncludedRef = item.TypeIdIncludedEntity }; derivedProductToComositeKeyMap.Add(dProduct.Key, item.CompositeKeyEntity.Key); derivedProductToIncludedTypeKeyMap.Add(dProduct.Key, item.TypeIdIncludedEntity.Key); } nameIndex++; }
static void Main(string[] args) { DerivedProduct dp = new DerivedProduct(); dp.MyIntProperty = 20; dp.MyStringProperty = "20"; // wait for input before exiting System.Console.WriteLine("Press enter to finish"); System.Console.ReadLine(); }
static void Main(string[] args) { // create a new instance of the Product class Product prod = new DerivedProduct();; // set the value of the property prod.ItemsInStock = 20; // print the value of the property Console.WriteLine("Stock {0}", prod.ItemsInStock); // wait for input before exiting Console.WriteLine("Press enter to finish"); Console.ReadLine(); }
static void Main(string[] args) { // create an object from the derived class DerivedProduct derivedObject = new DerivedProduct(); // upcast the objet to the base type BaseProduct upcastObject = derivedObject; // print out the field values Console.WriteLine("Derived Field: {0}", derivedObject.myField); Console.WriteLine("Base Field: {0}", upcastObject.myField); // wait for input before exiting System.Console.WriteLine("Press enter to finish"); System.Console.ReadLine(); }
static void Main(string[] args) { // create a new instance of the Product class DerivedProduct dp = new DerivedProduct(); Product prod = dp; // set the value of the fields prod.ItemsInStock = 20; Console.WriteLine("Stock DP {0}", dp.ItemsInStock); Console.WriteLine("Stock P {0}", prod.ItemsInStock); // wait for input before exiting Console.WriteLine("Press enter to finish"); Console.ReadLine(); }
protected override void PopulateData() { using (var session = Domain.OpenSession()) using (var transactionScope = session.OpenTransaction()) { _ = new DerivedProduct() { ProducibleItem = new ProducibleItem() { MeasureType = "A" } }; _ = new DerivedProduct() { ProducibleItem = new ProducibleItem() { MeasureType = "M" } }; _ = new DerivedProduct() { ProducibleItem = new ProducibleItem() { MeasureType = "B" } }; _ = new DerivedProduct() { ProducibleItem = new ProducibleItem() { MeasureType = "M" } }; _ = new DerivedProduct() { ProducibleItem = new ProducibleItem() { MeasureType = "C" } }; _ = new IntermediateProduct() { MeasureType = "D" }; _ = new IntermediateProduct() { MeasureType = "M" }; _ = new IntermediateProduct() { MeasureType = "E" }; _ = new IntermediateProduct() { MeasureType = "M" }; _ = new IntermediateProduct() { MeasureType = "F" }; _ = new IntermediateProduct() { MeasureType = "M" }; _ = new IntermediateProduct() { MeasureType = "G" }; transactionScope.Complete(); } }