StoreGeneratedPattern="Computed"

Posts   
 
    
Posts: 34
Joined: 11-Apr-2011
# Posted on: 18-Apr-2011 14:48:34   

Hello,

I'm using llbl v.3.1 - Entity Framework 4.0 - STE.

For concurrency mode I'm using Version column in each entity and timestamp in SQL(Sql Server 2008 ).

The column is inserted by SQL Server and I'd like to set up entity field as StoreGeneratedPattern ="Computed".

How can I set this option on column ?

BTW. In SQL 2008 timestamp is deprecated type. Replacement is "rowversion". Hovewer there is no rowversion in llbl. Could You please add such type?

L.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 18-Apr-2011 20:30:46   

leszeks1313 wrote:

Hello,

I'm using llbl v.3.1 - Entity Framework 4.0 - STE.

For concurrency mode I'm using Version column in each entity and timestamp in SQL(Sql Server 2008 ).

The column is inserted by SQL Server and I'd like to set up entity field as StoreGeneratedPattern ="Computed".

How can I set this option on column ?

Isn't that automatic? Hmm. In that case it is indeed a little bug in the template. We assumed it was up to the ef ado.net provider to insert a value in a timestamp column or not (in case of sqlserver, it's insane to insert a value in a timestamp column of course... ).

We'll look into this.

BTW. In SQL 2008 timestamp is deprecated type. Replacement is "rowversion". Hovewer there is no rowversion in llbl. Could You please add such type?

at the moment there's no sqlserver version which doesn't support image/ntext/text/timestamp, so we'll add the type at the soonest in the next version for v3.x. timestamp is a synonym for rowversion, under the hood the same type is used so for your own code it doesn't matter (the 'rowversion' type is used internally when you use timestamp, see: http://msdn.microsoft.com/en-us/library/ms177566.aspx)

So it's only for scripts with DDL SQL statements which are kept around to use rowversion, at the moment.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 34
Joined: 11-Apr-2011
# Posted on: 19-Apr-2011 09:20:49   

It is not automatic. Moreover you can set such attribute on other columns where database is changing value ( by trigger, computed column, function etc.) Typical usage is column CreatedDate where on sql side is GetDate() function.

So it should not depends on the column type. It should be an option like with concurrentmode.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 19-Apr-2011 09:54:37   

It does emit the Computed attribute when the field is indeed a computed column, as determined by the driver. I see it is limiting to do it like this and based on type it's limiting too, simply because it can be 'timestamp' is not a type which data is generated on the server.

We can easily add a setting in the frameworksettings file so it ends up in the list of settings to set for a field. The drawback of this is that it's a little cumbersome to set that setting for all timestamp fields. Some add these kind of fields to every table. So for now we'll add it automatically for timestamp on sqlserver to the templates, and we'll add the setting to the frameworksettings file for the fields. You can use the setting for fields like CreatedDate, and leave timestamp fields to the template.

(edit) It's a bit difficult to add the setting, or better: to use it in practice in the edmx template. The problem is mainly that the settings are defined on the entity field type and have effect on the target field. But there can be multiple entityfields mapped onto the same target field (e.g. you have 2 entities mapped onto the same table). This gives a problem as you perhaps enabled the setting on field F1 in E1, but not on F2 in E2, both F1 and F2 are mapped onto tablefield TF1.

So we'll go for timestamp + sqlserver for now. In the next v3.x version we're adding conventions and allow more changes to db table fields, e.g. allow you to edit the IsComputed flag on the table field, something which isn't possible now in the UI.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 19-Apr-2011 10:40:11   

Please copy the contents of the attached zip file into the folder: <llblgen pro installation folder>\Frameworks\Entity Framework\Templates\Shared\Shared

as administrator

Any timestamp field for sqlserver will now be emitted as computed.

Attachments
Filename File size Added on Approval
SQLServerTimestampcomputedFix.zip 12,440 19-Apr-2011 10:40.16 Approved
Frans Bouma | Lead developer LLBLGen Pro
chrissie
User
Posts: 84
Joined: 05-Oct-2010
# Posted on: 08-Jul-2011 10:24:01   

This is right, I just tested it! Thank you very much,

regards

Chris