c# - How to Save relation table data using EF6 -


 [datacontract]    public class commodity     {        [datamember]         [key]         public long id { get; set; }         [datamember]        [datatype(datatype.text)]        [stringlength(40)]        public string name { get; set; }         [datamember]        public virtual list<dailyprice> comoditydailyprices { get; set; }         [datamember]      public virtual list<dailyproduction> commoditydailyproduction { get;set; }      }  //==========================//   [datacontract]   public class currency   {     [datamember]     [key]     public long id { get; set; }      [datamember]     [datatype(datatype.text)]     [stringlength(10)]     public string name { get; set; }      [datamember]     public virtual list<dailyprice> dailyprices { get; set; }    }   //==========================//   [datacontract]   public class dailyprice   {     [datamember]     [key]     public long id { get; set; }      [datamember]     public long commodityid { get; set; }      [datamember]     //[foreignkey("commodityid")]     public virtual commodity commodity { get; set; }      [datamember]     public long currencyid { get; set; }      [datamember]     public virtual currency currency { get; set; }      [datamember]     [datatype(datatype.date)]     public datetime date { get; set; }      [datamember]     public double price { get; set; } }   //==========================//   public bool create(dailyprice _create)     {         using (var context = new dbcontext())         {             context.dailyprices.add(_create);             context.savechanges();             return true;         }     } 

//there relation between currencies ,commodities , daily-prices.so while saving dailyprice curriences , commodotes repeated values commodites 1 oil 2 gas 3 water 4 water.

for currencies

1 inr 2 usd 3 euro 4 sdg 9 euro

please let me known doing sumthing wrong.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -