Xid column type support

Xid column type support

Postby omatrot » Tue 15 Jan 2013 15:13

Hello,

I'm working with Npgsql provider and Entity Framework 5 with PostgreSQL 9.X, but we have so much problems with the System.Transaction support in this provider that we are in the process of evaluating dotConnect for PostgreSQL.

With Npgsql, I could include the hidden xmin column (of type XID) that is available on every table to enable Optimistic concurrency.

In my model, this column is set to be :

SSDL : <Property Name="xmin" Type="bigint" StoreGeneratedPattern="Computed" />
CSDL : <Property Name="xmin" Type="Int64" Nullable="false" p1:StoreGeneratedPattern="Computed" ConcurrencyMode="Fixed" p9:SetterAccess="Internal" xmlns:p9="http://schemas.microsoft.com/ado/2006/04/codegeneration" />

At runtime with dotConnect for PostgreSQL there is an exception while issuing a simple query on the entity :

Code: Select all
System.InvalidOperationException: The 'xmin' property on 'Person' could not be set to a 'String' value. You must set this property to a non-null value of type 'Int64'.
   at System.Data.Common.Internal.Materialization.Shaper.ErrorHandlingValueReader`1.GetValue(DbDataReader reader, Int32 ordinal)
   at System.Data.Common.Internal.Materialization.Shaper.GetPropertyValueWithErrorHandling[TProperty](Int32 ordinal, String propertyName, String typeName)
   at lambda_method(Closure , Shaper )
   at System.Data.Common.Internal.Materialization.Coordinator`1.ReadNextElement(Shaper shaper)
   at System.Data.Common.Internal.Materialization.Shaper`1.SimpleEnumerator.MoveNext()
   ...


Could you please explain what is happening here ?

By the way, If by any chance this problem is overcomed, I may have propbably another issue. The provider must return computed column with statements like "INSERT ... RETURNING xmin,..." and "UPDATE ... RETURNING xmin,..." otherwise, this will not work as the transaction id will be incorrect.

Is it the case ?

Any help appreciated.
Thanks in advance.
omatrot
 
Posts: 1
Joined: Mon 14 Jan 2013 15:47

Re: Xid column type support

Postby Shalex » Mon 21 Jan 2013 11:38

omatrot wrote:The 'xmin' property on 'Person' could not be set to a 'String' value. You must set this property to a non-null value of type 'Int64'.

Open your model with Entity Developer (it allows to modify both CSDL and SSDL in design time) and check settings for xmin column:
SSDL - Name=xmin, Store Generated Pattern=Computed, Type=bigint
CSDL - Name=Xmin, Store Generated Pattern=Computed, Type=Int64, Nullable=False, Concurrency Mode=Fixed Setter=Internal

After this, the record is successfully added in our test project with the following SQL:
INSERT INTO public.dept(deptno, dname, loc)
VALUES (:p0, :p1, :p2)
RETURNING xmin
Shalex
Devart Team
 
Posts: 7654
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for PostgreSQL