c# - Return column based on record in FK table -


There is a successful query to show to my vendors, but what I wanted to add now shows a column that Which vendor is selected or not (displayed as a checkbox column) These selections are stored in vendors, in which the selected FK profiles are included in the ID and username they have selected. So when the current user sees vendors then there will be matches for some vendors and not for others.

How do I modify the query? Note, where the above stream is to be completed only to the vendors selected by the current user, but for all the vendors I want, when displayed with the right / wrong (checkbox) column for each vendor they choose pay attention.

  Public IEnumerable & lt; BrowseVendorModel & gt; BrowseVendors () {IQueryable & lt; BrowseVendorModel & gt; ViewModel = _db.VendorProfiles. Include ("seller selected"). Select (S = & gt; New Browser Window Modal {ProfileID = s.ProfileID, Name = s.Name, CompanyName = s.CompanyName, City = s.City, State = s State, Date Date = s.DateCreated}). Where (x => x.endors selected. Selection (s = & gt; s.UserName)). (HttpContext.Current.User.Identity.Name). Oderby (v => V. Profile ID); Return visual model; }   

Enter image details here

Add a property selected ( boolean ) to the visual model:

  Public IEnumerable & lt; BrowseVendorModel & gt; BrowseVendors () {IQueryable & lt; BrowseVendorModel & gt; ViewModel = _db.VendorProfiles. Include ("seller selected"). Select (S = & gt; New Browser Window Modal {ProfileID = s.ProfileID, Name = s.Name, CompanyName = s.CompanyName, City = s.City, State = s State, Date Dated = s.DateCreated, Selected = x .vendorsSelected.Select (s = & gt; s.UserName) .included (HttpContext.Current.User.Identity.Name)}). Oderby (v = & gt; v. ProfileID); Return visual model; }    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -