c# - Entity Framework calculated property -


i have following classes in ef6

items ------------- public int       itemid public string    itemname public decimal   itemprice public virtual   list<listpricesitems> listpricesitems public decimal   itemdiscountedprice (need calculate this)  listprices ---------------- public int    listid public string listdescription public date   listvaliduntildate   listpricesitems ----------------- public int        lprid public int        listid public int        itemid public decimal    itemdiscountedprice 

what need have itemdiscountedprice in items following

        [notmapped]         public decimal itemdiscountedprice         {                         {                 if(listpricesitems.listprices.listvaliduntildate > date.now()){                     return listpricesitems.itemdiscountedprice ?? itemprice;                 }              }         } 

is possible ? if discount policy still active, check if itemdiscountedprice null , give standard itemprice if null.

updated

public partial class items     {         [key]         [databasegenerated(databasegeneratedoption.none)]         public int itemid { get; set; }           public string itemname { get; set; }            [column(typename = "money")]         public decimal? itemprice { get; set; }          public virtual icollection<listpricesitems> listpricesitems { get; set; }          [notmapped]         public decimal itemdiscountedprice          {                         {                  return ......................              }         }       }       public partial class listprices     {         [key]         public int listid { get; set; }          public string listdescription { get; set; }          [column(typename = "datetime2")]         public datetime? listvaliduntildate { get; set; }          public virtual icollection<listpricesitems> listpricesitems { get; set; }      }      public partial class listpricesitems     {         [key]         public int lprid { get; set; }          public int? listid { get; set; }          public int? itemid { get; set; }          [column(typename = "money")]         public decimal? itemdiscountedprice { get; set; }          public virtual listprices listprices { get; set; }     } 

here on listpricesitems


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -