Ronjon
Ronjon

Reputation: 1849

How to show custom query result to view mvc3 Razor

I have Custom query Result as

public ActionResult Index()
        {
            var Query = (from E in db.SITE_MASTER.AsEnumerable()
                         where E.IS_PAGE == true
                         select new 
                         {
                             E.POST_TITLE,
                             E.POST_TEXT
                         }).ToList();
            return View(Query);
        }

Now,

How can I make view for this result or How can I create View for this Result Query.

Thanks...

Upvotes: 0

Views: 128

Answers (1)

Rory McCrossan
Rory McCrossan

Reputation: 337610

You can pass an anonymous type as a model, but please don't. It's ugly and will lead to maintenance problems.

As an alternative either use the ViewBag or create concrete type and pass that.

Upvotes: 1

Related Questions