Note that there are some explanatory texts on larger screens.

plurals
  1. POplease help cant get my head around multiple models in one view
    text
    copied!<p>i have tried till my head hurts and have been reading so much my eyes now bleed.</p> <p>i have a controller, and i want to get one set of data for the order and one list for the order items.</p> <p>i have created a order class and a order items class, and trying to get it so that the order will have a list of order items but it is crashing my brain i dont know if im on the right path or not or if im missing something i just dont get it.</p> <p>here is my code</p> <pre><code>public ActionResult finaliseQuote(string quoteid) { ViewData["quoteid"] = quoteid; // populate our class with data about our quote so far var orders = (from q in quote.All() where q.quoteid == quoteid select q).SingleOrDefault(); //IList&lt;quoteParts&gt; orderItemsList = new quoteParts(orderitems); (this not work) quoteParts myparts = new quoteParts((from qi in quoteItem.All() where qi.quote_id == quoteid select qi).SingleOrDefault()); // compiles but this is not a list ????? return View(); } </code></pre> <p>then my 2 classes:</p> <pre><code> public class quoteInfo { public IList&lt;quoteParts&gt; items { get; set; } public DateTime datecreated { get; set; } public double totalcost { get; set; } public string quotesid { get; set; } public quoteInfo(quote myquote) { items = new List&lt;quoteParts&gt;(); } } public class quoteParts { public string itemsid { get; set; } public bool isextra { get; set; } public string qty { get; set; } public string mx { get; set; } public string my { get; set; } public string prodid { get; set; } public quoteParts(quoteItem item) { itemsid = item.itemid; isextra = item.isextra; qty = item.qty; mx = item.measureX.ToString(); my = item.measureY.ToString(); prodid = item.prodid; } } </code></pre> <p>i am hoping that i can create a view and then reference quoteInfo and also loop through quoteParts in another section of the page.</p> <p>i know to some this may seem like i am being lazy but im not i learn when i get it right once it works it is then that i understand, right now i want to do OOP etc but seem to be hitting wall after wall.</p> <p>many thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload