C
C#2y ago
Hardy

❔ DBSet manipulation

For the below code, I get all of the Customers. I want to get only those whose ID is less than 10.
// GET: Order/Edit/5
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Order order = db.Orders.Find(id);
if (order == null)
{
return HttpNotFound();
}

ViewBag.VesselID = new SelectList(db.Customers, "CustomerID", "CustomerName", order.CustomerID);
return View(order);
}
// GET: Order/Edit/5
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Order order = db.Orders.Find(id);
if (order == null)
{
return HttpNotFound();
}

ViewBag.VesselID = new SelectList(db.Customers, "CustomerID", "CustomerName", order.CustomerID);
return View(order);
}
2 Replies
Angius
Angius2y ago
.Where()
var cheapProducts = await _context.Products
.Where(p => p.Price < 20)
.ToListAsync();
var cheapProducts = await _context.Products
.Where(p => p.Price < 20)
.ToListAsync();
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server