How to use ApplicationDbContext with Editor?
How to use ApplicationDbContext with Editor?
Telefisch
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?
This discussion has been closed.
Answers
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
I will be back here, when I get the Editor run.
If I ever get it run
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();
...I solved it without Editor and Datatables.
Thanks for trying