I have two models, categories and subcategory, several relationships.
Then I got a model named 'notice' which has one relation with sub-category (in the form of suburban FK).
Users add subcategories they want to monitor. They should be noticed when something that is inside the subcategory
Now I'm trying to print out the information so the user gets an overview about this, which subcats are being monitored. The current I have solved by doing this is doing this way: The problem is that I need to print it up, as I have shown above and therefore need to make a separate selection (for categories) and By doing this I have to lose access to other category properties, for example the property of the mark that I want. I am stuck and know that there is a better way of doing this, but I can not understand it. My models are complete here: Any suggestions? I think what you are .Select (X => New CheckedNoticesViewModel () {CategoryID = X, looking for Edit: Maybe it can be: } Subcats andCheckedNotices = from subcat in db.Subcategories = notice db.Notices.Where to join (X = & Gt; x.CompanyId == company.CompanyId) is equivalent to subcat.SubcategoryId notice.SubcategoryId prodGroup.DefaultEfEmpty from item in prodGroup (in) new Che CkedNoticesViewModel () {Selection of classID = subcat.CategoryId, category = subcat.Category, subcategory = subcat, checked = (item.subcategoryId = null false: true)};
Public category category {public int category iid {received; Set; } Public string icon {get; Set; } Public string title {get; Set; } Public identification & lt; Subcategory & gt; Subcategories {Receive; Set; }} Public class subcategory {public int subcategoryId {get; Set; } Public string title {get; Set; } Public Int Category IID {Received; Set; } Public Virtual Class Category {Received; Set; }} Public class notice {public int notice {receipt; Set; } Set {receive} the public int subcategory; } Public Virtual Subcategory Subcategory {get; Set; } Public Entity Company ID {Received; Set; } Public Virtual Company Company {Received; Set; }}
is the result = db.Notices.Where (x.CompanyId == company.CompanyId = X =>). Subcategory.CategoryId, Category = x.Subcategory. Category, Subcategory = x.Subcategory, Checked = x.SubcategoryId = Null False: True} .GroupBy (y = & gt; y.CategoryId); foreach (result in result) {print (result.c.e. Information that you want to print); foreach (see the notes checked in the resulting check mode) {Print (check-in) Tees View Model. (Information that you want to print);}}
foreach (DB Various categories in categories) {print (category titles); foreach (category sub subcategoryNotice.Subcategories.GroupJoin (db.Notices, x => X.SubcategoryId, y = & gt; y.SubcategoryId, (x, Y) = & gt; new {sub-category = x, notice = y})) {print (sub-classification. Suggestions category. "+ (SubCategoryNote NoteAnyone (x => X.CompanyId == 1)? Correct));}
No comments:
Post a Comment