How to use ApplicationDbContext with Editor?

How to use ApplicationDbContext with Editor?

TelefischTelefisch Posts: 14Questions: 3Answers: 0

Hello Forum,
trying to solve my issues I wonder why I Always should establish another Connection to my database instead of using the ApplicationDbContext, which is already open in my Controller?

How can I use this for the Editor in my MVC Project?

Answers

  • allanallan Posts: 61,726Questions: 1Answers: 10,109 Site admin

    If you have a database connection already, then yes, absolutely, use that! You need to pass in an instance of the Database class provided by the libraries, but you can readily use an existing database connection for that if you want.

    The methods I used in the examples aren't always going to be the best option for any other implementation. I've tried to keep them generic so they apply in many difference cases.

    Regards,
    Allan

  • TelefischTelefisch Posts: 14Questions: 3Answers: 0

    I will be back here, when I get the Editor run.
    If I ever get it run :(

  • TelefischTelefisch Posts: 14Questions: 3Answers: 0

    So can you please give me an example on how to use this Kind of database-connection?

    private ApplicationDbContext db = new ApplicationDbContext();

    Normally I would fetch the data this way:

    List<FunctionGroup> functionGroupList = db.FunctionGroups.Where(a => a.ProjectId == projectId).ToList();

  • TelefischTelefisch Posts: 14Questions: 3Answers: 0

    ...I solved it without Editor and Datatables.
    Thanks for trying

This discussion has been closed.