Hi,
i realized that an update on a field, declared like this, is not commited.
How am i supposed to make an update on a field like "state", which has a "defaultvalue=created" property set in the database?
I want the defaultvalue to be used, but also the possibility to update it later..
THanks for any advice
Update on a "Auto Generated Value=true" field
If to set the [Column(IsDbGenerated=true)] attribute, the field will be modified at the server side (e.g. in trigger), and all attempts to send to the server the new value from the client side will fail.
Setting the DEFAULT keyword with some value in the CREATE TABLE SQL during creating the table is not taken into account at the client side. Probably it should work only during Insert (not Update). And for Insert, you need to assign this value in the constructor of your class manually.
If we've got you wrong, please explain more clearly the meaning of the "Auto Generated Value" and "defaultvalue" terms you used in the post above.
Please refer to MSDN for detailed information about using the IsDbGenerated attribute.
Setting the DEFAULT keyword with some value in the CREATE TABLE SQL during creating the table is not taken into account at the client side. Probably it should work only during Insert (not Update). And for Insert, you need to assign this value in the constructor of your class manually.
If we've got you wrong, please explain more clearly the meaning of the "Auto Generated Value" and "defaultvalue" terms you used in the post above.
Please refer to MSDN for detailed information about using the IsDbGenerated attribute.
Iam setting the "Auto generated Value" property for the field "status" in the entity-designer to "true" ( for my table-entity )...
Now, LINQ knows that this field shouldn't be set to "null", but to be chopped off from the insert into command .. means:
What LINQ is doing with status -> auto-generated-value=true:
-> insert into xyz ( description ) values ( "test" )
---> status value set to the default value (e.g. "created" )
What LINQ is doing with status -> auto-generated-value=false:
-> insert into xyz ( description, status ) values ( "test", null )
------> status value set to null
So, now i need to update the status field for whatever reason...
And you say that's not possible with the framework? That means that's is impossible to use the databases "default" feature?!
Well, for my understanding that'd be a bug then...
Now, LINQ knows that this field shouldn't be set to "null", but to be chopped off from the insert into command .. means:
What LINQ is doing with status -> auto-generated-value=true:
-> insert into xyz ( description ) values ( "test" )
---> status value set to the default value (e.g. "created" )
What LINQ is doing with status -> auto-generated-value=false:
-> insert into xyz ( description, status ) values ( "test", null )
------> status value set to null
So, now i need to update the status field for whatever reason...
And you say that's not possible with the framework? That means that's is impossible to use the databases "default" feature?!
Well, for my understanding that'd be a bug then...
The auto-generated-value=true parameter of the Column attribute was implemented for the AutoIncrement type columns which always are filled up at the server side; these columns cannot be updated with the value from the client side. Working with the Default columns is like working with the AutoIncrement columns only during Insert from the client side. But that's all.
Working with the DEFAULT value columns is not supported in LINQ automatically. It can be implemented by setting the value at the client side in constructor.
Working with the DEFAULT value columns is not supported in LINQ automatically. It can be implemented by setting the value at the client side in constructor.