LinqToSql UpdateCheck

Posts   
 
    
Posts: 134
Joined: 10-Jan-2007
# Posted on: 29-Jun-2010 21:36:29   

I like to turn off Optimistic Concurrency for LinqToSql by setting UpdateCheck="Never" for each column. I have modified the base templates (externalMappingFile.lpt line 108 and entityClass.lpt line 222) to always be true.

My question is, can I add my own Settings and get to that in the template? So I can use currentProject.GetRealBoolSettingValue("MySettingName")? Then I could just toggle it on/off.

Brian

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 30-Jun-2010 06:54:51   

Why modify the standard templates while you can use Attributes in LLBLGen Designer Code generation info tab on Project Properties and/or Entity Editor?

Please read the link. You can add it to the project, to the entity or field elements. Just add the attribute as Column(UpdateCheck=UpdateCheck.Never). You can write a plugin that switch the value of all elements or you can simply use the attribute at Project Properties and then remove it form not involved elements.

David Elizondo | LLBLGen Support Team
Posts: 134
Joined: 10-Jan-2007
# Posted on: 30-Jun-2010 15:13:26   

In LinqToSql you cannot have more than 1 Column attribute, it needs to be in the one generated, or in the case of the xml config, on that element.

You can write a plugin that switch the value of all elements or you can simply use the attribute at Project Properties and then remove it form not involved elements.

Not sure how this can help considering the single Column attribute.

So is it possible to add our own settings?

Brian

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39590
Joined: 17-Aug-2003
# Posted on: 30-Jun-2010 16:14:36   

Yes, you can. See: http://www.llblgen.com/documentation/3.0/SDK/hh_goto.htm#definingcustomsettings.htm

The settings, if specified for the same target framework etc., are merged with the other ones and editable like the other settings. You have to alter the templates of course to consume them.

Is there any useful usage for this, i.e. should we add this as a setting? (I don't see the reason for disabling concurrency for linq to sql, but there might be a use case?)

Frans Bouma | Lead developer LLBLGen Pro
Posts: 134
Joined: 10-Jan-2007
# Posted on: 30-Jun-2010 16:54:01   

Yes, you can.

Awesome. Very happy.

Is there any useful usage for this

In our web world, we generally just use last one wins, so I turn it off for 2 reasons: 1. Performance, it adds a where clause check for every field 2. You cannot Attach an entity that has all the fields because it will want the original values for the concurrency check. This forces you to reload the object every time.

There is another way to do optimistic concurrency with a timestamp, which would be a good option, this article sums it up pretty well: http://jonkruger.com/blog/2008/02/10/linq-to-sql-in-disconnectedn-tier-scenarios-saving-an-object/. When I have a timestamp in the table, the L2S designer marks all fields UpdateCheck=Never and sets the timestamp=true. Here is the DBML line:

<Column Name="timestamp" Type="System.Data.Linq.Binary" DbType="rowversion NOT NULL" CanBeNull="false" IsVersion="true" />

and the column attribute is:

[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_timestamp", AutoSync=AutoSync.Always, DbType="rowversion NOT NULL", CanBeNull=false, IsDbGenerated=true, IsVersion=true, UpdateCheck=UpdateCheck.Never)]

Personally I like it off and I like LLBLGens framework better, but I am trying to support a current L2S project and not use the crappy MS interface.

Brian

Brian

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39590
Joined: 17-Aug-2003
# Posted on: 30-Jun-2010 17:00:59   

Thanks for the info. Looks like a good addition for the stuff we generate. For linq to sql we ported more or less the templates of 2.6 over to 3.0 so we didn't do a lot of advanced stuff like separation of projects / poco stuff. This is a setting which could benefit all users, so we'll add it (in the coming weeks simple_smile )

Frans Bouma | Lead developer LLBLGen Pro