Need Startup-help with Entity Framework

Need Startup-help with Entity Framework

TelefischTelefisch Posts: 14Questions: 3Answers: 0

Hi guys,
I'm a bit of a noob with Ajax and jscript, so I Need a Little help with starting the first table.

In my view, I'd like to populate a datatable with some recordsets, that are stored in a SQL-database.
For this, of Course I have my Datamodels.
First Question, is the Ajax-call the Right way to read and write data?

Perhaps, first I just want to read Data, so I tried some lines like this (here only one Column I'd like to Display):

$(document).ready(function () {
$('#properties').DataTable({
ajax: {
url: '/Properties/GetList',
dataSrc: '',
dataType: 'json'
},
columns: [
{ data: 'Name' }
]
});
});

The Controller Action is triggered as expected:

public ActionResult GetList()
{
List<Property> propertyList = db.Properties.ToList();
return Json(new { data = dataList }, JsonRequestBehavior.AllowGet);
}

But with this, I get an internal Server Error (500), after the Actionresult is returned.
I have no Idea how to get over this.
Can please someone gimme a hint?

Thanks

Carsten

Answers

  • TelefischTelefisch Posts: 14Questions: 3Answers: 0
    edited October 2018

    I think I'm a bit closer at my solution.
    It seems to have something to do with a circular reference error, while serializing the EF-Object.

    So is there a better way to connect the datatable to the enity Framework?
    Or is there a usefull solution for the json-circular Problem?

This discussion has been closed.