c# - How to link a NotMapped property manually as entity? -


i have 2 classes:

public partial class registry {     [key]     public int id { get; set; }     public string title{ get; set; }       [notmapped]     public virtual category category { get; set; } }  public partial class category {     [key]     public int id { get; set; }     public string titlesearch { get; set; }     public string name{ get; set; } } 

i want fill registry.category first category registry.title contains category.searchtitle, using like operator. it´s possible make link automatically when call registry.category, , see if category not null?

i want make this:

    if(registry.category != null){     categoryname = registry.category.name;     } 

updated tried this, , worked:

    [notmapped]     public virtual category category {          {     context db = new context();     var category = db.categories.where(e=> title.contains(e.titlesearch)).firstordefault();     return category;     }     } 


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -