views:

4

answers:

0

I have a practise of setting UpdateCheck="Never" for most table properties in the DBML file. This is because I don't want the extra overhead from concurrency checking (see Turn Optimistic Concurrency Off Unless You Need It)

However, I have noticed a strange side effect of doing this. Can anyone explain this?

If I am updating a particular entity through a LinqDataSource (e.g. a ListView bound to a LinqDataSource) and I check the object's new state inside the LinqDataSource's OnUpdating (or OnUpdated) event, like this:

    SalesHistory sh = (SalesHistory)e.NewObject;

... then any properties that have UpdateCheck="Never" have no value (e.g. integer's have zero value). This is a big problem, because the database update requires this data!

However, if inside the same method I get the same entity from the database with a LINQ query, then the object has complete property values, e.g.

    var test = (from s in _dc.SalesHistories where s.salereport_id == 67664 select s).Single();

There just seems to be a problem getting access to the property values inside LinqDataSource event handlers. The property values are fine if accessed through an Eval function in the ListView, e.g.

<asp:LinkButton ID="lnkViewSale" runat="server" OnClick="lnkViewSale_Click"
                            CommandName='<%# Eval("salereport_id") %>' Text="Details" />

Is there a good explanation for this, and is there any way to get full access to the property values in the event handlers without turning on the UpdateCheck?

EDIT: Noticed a second strange thing: properties that have IsDbGenerated="true", in addition to requiring UpdateCheck="Always", also have to have AutoSync="OnInsert" set. If AutoSync="Always" then the property value is also missing inside the LinqDataSource event handlers.