EF 5 beta: how to modify update query at runtime? RRS feed

  • Question

  • is it possible to override the default update query used by an EntityDataSource at runtime?

    i have a need to exclude a column from update when it is not changing because the bound telerik RadGrid control does not handle binary data (in this case pictures) the same way as other columns' data types - meaning that the data is no longer available after selecting. since the binary data update value is null when it does not change, and my column constraint is Not Null, an update error is generated. even without the contraint it would null it out, something i do not want.

    so, i can modify the update statement if possible. otherwise i have to create a mapped stored procedure to update the database. does ef5 still have an all or nothing policy on this matter in re crud? ie all crud operations have to be mapped to stored procedures if any is?

    i am not sure that getting the original data would help, but does entitydatasource cache it if viewstate is enabled?

    Saturday, May 5, 2012 9:22 PM


  • Hi tony,

    Please repost your question here: http://forums.asp.net/54.aspx/1?DataSource+Controls+SqlDataSource+ObjectDataSource+etc.

    BTW, From the document in MSDN, You can submit updates to the data source from outside a data-bound control by adding, modifying, and deleting objects in an ObjectContext. For more information, see How to: Add, Modify, and Delete Objects (Entity Framework). After you call the SaveChanges method to commit the changes in the ObjectContext to the data source, call the DataBind method on the data-bound control to update the control with the latest data from the data source.

    Have a nice day.

    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Allen_MSDN Wednesday, June 6, 2012 4:17 AM
    Monday, May 7, 2012 8:16 AM