Search code examples
entity-frameworkcatel

Updateing a Table with a Stored Procedure or Functions in Catel


I've set up a database with EF6 and Code First and I am using Catel's Repository Pattern to communicate with the database.

Now, I am curious as to how you would call a stored procedure (or even a Scalar Valued Function) on my database using Catel. Any suggestions?


Solution

  • You should still be able to call the stored procedure using the DbContext itself as you usually would:

    using (var dbContextManager = DbContextManager<MyEntities>.GetManager())
    {
        var dbContext = dbContextManager.DbContext;
        var result = dbContext.Database.SqlQuery<ReturnType>("storedProcedureName", params);
    }
    

    https://msdn.microsoft.com/en-us/library/gg696545(v=vs.113).aspx