Reputation: 182
I´ve a MVC 5 Project in VS 2013 with ODP.net Connection to an oracle database and entity framework 6.
I also have a view in my database which holds all information I need for my select call. I need to get all the information out of the database and display it on the webpage. I get the right number of elements in my list, but they are all empty.
I´ve read that my objects have to contain the correct names of the elements, but that isn´t working.
public class HomeController : Controller
{
public ActionResult Index()
{
using (var context = new DatabaseEntities())
{
var result =
context.Database.SqlQuery<MyEntity>(
"SELECT (case when HERKUNFT = 'AVZ' then ANLA_NR else LAG_NR end) \"LagerAnlage\", " +
"STO_NR \"Standort\", " +
"ART_NR \"Artikelnummer\", " +
"ART_KBEZ || '\n' || ART_BEZ1 || '\n' || ART_BEZ2 \"Artikelbezeichnung\", " +
"SN \"SN\", " +
"TO_CHAR(DTZUGANG, 'DD.MM.YYYY') \"Zugangsdatum\", " +
"TO_CHAR(DTABGANG, 'DD.MM.YYYY') \"Abgangsdatum\", " +
"WERT \"WertStk\", " +
"MENGE \"Stk\" " +
"FROM view_useravz " +
"WHERE user_cd = 'USERNAME' " +
"ORDER BY DTZUGANG");
var list = result.ToList();
}
return View();
}
}
class MyEntity
{
public string LagerAnlage;
public string Standort;
public string Artikelnummer;
public string Artikelbezeichnung;
public string SN;
public string Zugangsdatum;
public string Abgangsdatum;
public string WertStk;
public string Stk;
}
Upvotes: 0
Views: 973
Reputation: 182
I don´t know why, but now I got an Error and was able to find a solution.
I chose the wrong types in my Class. When i set WertStk and Stk to int everything worked.
Upvotes: 1