Как создать список записей в представлении на основе значений в другой таблице
I have a view that produces Vendors that are attached to parts. These parts have Letters at the beginning of them. I have a table that has values for the letters. So when selected it shows a list of vendors and their prices. I do not have a Selling price in the table and that is where this other table comes in. Based on the letter it begins with the Average cost should be multiplied by the value in this table. The table that i will refer to as ProductMaster has the VendorId, MaterialId, LastCost, AverageCost, and StandardCost. The table referred to as BillingSettings has a list of records with a type and the value to be used. ProductMaster Also has reference to Vendors, Parts, and BillingSettings. I have tried a few things but have not been successful in getting this to work. It seems like each route i take there is something in the code that it doesnt like. All of these are of decimal Type and the Values to be multiplied are of Type Money. In MSSQL. Below is what i have currently and has an issue with the select statement.
Что я уже пробовал:
public ActionResult Index(Guid id) { var dict = db.BillingSettings.Where(t => t.Types == 1).Select(x => new { x.StartingValues, x.Value }); var productMaster = db.ProductMaster.Include(p => p.Parts).Include(p => p.Vendor).Include(p => p.BillSettings).Where(m => m.Material == id).Select(n => { n.SellingPrice = n.AverageCost * (dict.FirstOrDefault(x => n.Parts.PartNumber.StartsWith(x.StartingValues))?.Value ?? 1); }); return View(productMaster.ToList()); }