Hello Community,
I am using Entity Framework 5 DbContext API. How do I go about making the following easier for me, so I don't have to repeat the code for various tables? In the code I am adding a record to MiscDB1, but I don't want to have to retype everything out again for CapacitorsDB1, ResistorsDB1, etc...
Any help would be greatly appreciated. Thank you!
RTCDBEntities DbContext = new RTCDBEntities(); CapacitorsDB CapacitorsDB1 = new CapacitorsDB(); ResistorsDB ResistorsDB1 = new ResistorsDB(); MiscDB MiscDB1 = new MiscDB(); // Sets values MiscDB1.RTC_PN = this.rtcpntext; MiscDB1.Description = this.descriptiontext; MiscDB1.KeyValue = this.keyvaluetext; MiscDB1.ComponentTypeID = this.comptypeint; MiscDB1.ComponentSubtypeID = this.compsubtypeint; MiscDB1.PackageTypeID = this.packtypeint; MiscDB1.PackageSubtypeID = this.packsubtypeint; MiscDB1.MountType = this.mounttypetext; MiscDB1.AssemblyStep = this.assemblysteptext; MiscDB1.FeederSize = this.feedersizetext; MiscDB1.Width = this.widthdeci; MiscDB1.Length = this.lengthdeci; MiscDB1.Height = this.heightdeci; MiscDB1.SupplierID = this.supplierint; MiscDB1.SupplierPN = this.supplierpntext; MiscDB1.ManufacturerID = this.mfgint; MiscDB1.MfgPN = this.mfgpntext; MiscDB1.AltManufacturerID = this.altmfgint; MiscDB1.AltMfgPN = this.altmfgpntext; MiscDB1.ComponentLink1Description = this.link1desctext; MiscDB1.ComponentLink1URL = this.link1urltext; MiscDB1.ComponentLink2Description = this.link2desctext; MiscDB1.ComponentLink2URL = this.link2urltext; MiscDB1.Price_1 = this.price1deci; MiscDB1.Price_100 = this.price100deci; MiscDB1.Price_1000 = this.price1000deci; MiscDB1.SymbolRefID = this.symbolrefint; MiscDB1.SymbolPathID = this.symbolpathint; MiscDB1.FootprintRefID = this.symbolrefint; MiscDB1.FootprintPathID = this.footpathint; DbContext.MiscDBs.Add(MiscDB1);