none
EF: Stored Procedures and custom child (or parent) loading RRS feed

  • Question

  • We use aspects of EF but we have many restrictions re: direct table access. EF provide some clear cut support through function imports and mapping crud. 

    However, I am wondering what steps can be taken to overload the loading of relationships (e.g. Customer.Orders). What is the best way to have EF call a stored procedure instead of a direct query. In general, I would like to take advantage of the O-R mapping but control how data is read-written from the database. If worst come to worst one could cook up something with T4. I have come across some examples of people saying that Linq -Sql you can overload the LoadOrders for example. I have not tried this yet.

    Thoughts?

    Saturday, July 16, 2011 8:59 AM

Answers

All replies

  • Hi sirsh;

    Here is a link to a short video showing how to use stored procedures in EF and how to use them to do the inserts, update and deletes with stored procedures.

    Practical Entity Framework for C#: Stored Procedures in Entity Framework

     


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Saturday, July 16, 2011 3:43 PM
  • Also you may want to consider the CollectionViewSource filter which is an abstract of the content within a datagrid.  What's nice about it, is that it allows you to filter data, without affecting the source.
    JP
    Saturday, July 16, 2011 4:29 PM