Note that there are some explanatory texts on larger screens.

plurals
  1. POJoin LINQ with a List<> in select new
    primarykey
    data
    text
    <p>hi first time im asking here so il try to do it correctly</p> <p>i have a problem im making a shopping basket and im nearly there but always a but</p> <p>what i want to have is something like this</p> <pre><code>List&lt;HKurv&gt; KurvInnhold = (List&lt;HKurv&gt;)Session["KurvInnhold"]; DataClasses1DataContext db = new DataClasses1DataContext(); if (Session["KurvInnhold"] != null) { var query = from a in db.Cabinets from b in db.Commodities from e in db.sArticleNumbers from d in KurvInnhold where d.VareKjøpt.Contains(e.ArtNum) &amp;&amp; a.ArticleNumberID == e.ID &amp;&amp; a.ArticleNumberID == b.ArticleNumberID select new { BestiltAntall = d.AntallValgt, Price = b.Price, ModelName = a.ModelName, }; Handlekurv1.DataSource = query; Handlekurv1.DataBind(); } </code></pre> <p>But it does not allow for usage of db and list&lt;> in same query</p> <p>Solved! Modified magnus's answer</p> <pre><code> var kjopKollonne = from p in KurvInnhold select p.VareKjøpt; var query1 = (from a in db.Cabinets from b in db.Commodities from e in db.sArticleNumbers where kjopKollonne.Contains(e.ArtNum) &amp;&amp; a.ArticleNumberID == e.ID &amp;&amp; a.ArticleNumberID == b.ArticleNumberID select new { ArtNum = e.ArtNum, Price = b.Price, ModelName = a.ModelName, }).ToList(); var query2 = from a in query1 join b in KurvInnhold on a.ArtNum equals b.VareKjøpt select new { BestiltAntall = b.AntallValgt, Price = a.Price, ModelName = a.ModelName, }; Handlekurv1.DataSource = query2; Handlekurv1.DataBind(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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