I'm doing a little project where it's my first time using MVC 4.0 with Entity Framework 5 + Web API.
I brought in to my model only 1 view (vw0) and I want to query this view to display it on my web page.
This view is a UNION of 2 other views.
SELECT * FROM vw1
UNION ALL
SELECT * FROM Vw2
vw0 brings back over a million records. In order for me to just test this, I tried to do this:
// GET: /Data/
public ActionResult Index()
{
return View(db.Data_vw_0.ToList().Take(5));
}
However, every time I try to go to:
*/Data/
I get the following error:
OutOfMemoryException was unhandled by user code
An exception of type 'System.OutOfMemoryException' occurred in System.Data.Entity.dll but was not handled in user code.
I'm not sure what I'm missing here. I'm new to this whole thing so I needed a hand.
I'm just trying to display the data on the web page.
I was able to display data normally if I used a database table but for some reason with this view, it isn't working.
The view DOES work if I go straight into SQL and try to run it.
My question is, do I need to add both the views that are PART of the mother view (vw0) AS WELL AS the tables they relate to OR do I just have to add the ONE view to my model (vw0)?
The answer was no, I don't need to add the tables related to the view. I decided to use the actual tables and query them instead of using the Views -- they were giving me too many issues.