FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Making good/ proper line queries in c#?
NewsProgramming Languages

Making good/ proper line queries in c#?

via Dev.toFaithInErrorsZORO4h ago

Query ?:var customerOrdersQuery = (from c in db.Customers join o in db.Orders on c.CustomerId equals o.CustomerId select new { CustomerName = c.Name, OrderDate = o.OrderDate }).ToList(); Method:var customerOrdersMethod = db.Customers .Join( db.Orders, // 1. Table to join c => c.CustomerId, // 2. Key from the first table (Customers) o => o.CustomerId, // 3. Key from the second table (Orders) (c, o) => new // 4. The data you want to select { CustomerName = c.Name, OrderDate = o.OrderDate } ).ToList(); And then to display : @model IEnumerable @{ ViewData["Title"] = "Full Order Report"; } <h2>Customer Order Report</h2> <table> <thead> <tr> <th>Customer Name</th> <th>Product Purchased</th> <th>Date of Order</th> </tr> </thead> <tbody> @* Loop through the joined data stored in the ViewModels *@ @foreach (var item in Model) { <tr> <td>@item.CustomerName</td> <td>@item.ProductName</td> <td>@Html.DisplayFor(modelItem =&gt; item.OrderDate)</td> </tr> } </tbody> </table>

Continue reading on Dev.to

Opens in a new tab

Read Full Article
6 views

Related Articles

News

The Tooling Layer. What Sits Around Models and Why It Matters.

Medium Programming • 4h ago

News

FlowG - Road to 1.0

Lobsters • 4h ago

Kia shows off small cars in NY: The 2027 EV3 and 2027 Seltos Hybrid
News

Kia shows off small cars in NY: The 2027 EV3 and 2027 Seltos Hybrid

Ars Technica • 4h ago

The New Era of Militia Influencers
News

The New Era of Militia Influencers

Wired • 4h ago

This Android camera accessory helped me spot a hidden electrical hazard just in time
News

This Android camera accessory helped me spot a hidden electrical hazard just in time

ZDNet • 5h ago

Discover More Articles