开发者

List Database Entries According to Condition MVC 3

I am developing an MVC 3 application in C# and I would like to know how to list database entries, based on a condition. In my case, I only want to display invoices that have the status "Paid" or "Partly Paid".

So this is where I list them:

    public ViewResult Index()
    {

        var invoices = db.In开发者_开发知识库voice.Include(c => c.Client);
        return View(db.Invoice.ToList());
    }

How I would I add the condition into this code?

Thanks, Amy


Try this:

public ViewResult Index()
{

    var invoices = db.Invoice.Include(c => c.Client).Where(i => i.Status !="Confirmed";
    return View(invoices.ToList());
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜