MySQL timestamp

61 views
Skip to first unread message

James Darbyshire

unread,
Sep 18, 2010, 3:25:42 AM9/18/10
to dbl...@googlegroups.com
Hi all,

For MySQL column RowVersion of type timestamp, I am getting a compile time error in VS 2010:

>> Error 1 DBML1005: Mapping between DbType 'timestamp' and Type 'System.DateTime' in Column 'RowVersion' of Type 'Activity' is not supported. 0 0

Now that definitely makes sense as they are 2 different data types... But how do I use MySQL timestamps and DBLinq for optimistic concurrency?

Thanks,

James
--
Regards,

James Darbyshire
jamesda...@gmail.com

James Darbyshire

unread,
Sep 18, 2010, 8:09:55 AM9/18/10
to dbl...@googlegroups.com
According to this website (http://msdn.microsoft.com/en-us/library/bb386947.aspx) timestamp should be binary or byte[] type, yet dbmetal is creating a dbml mapping to DateTime.

Is this correct?

Jonathan Pryor

unread,
Sep 20, 2010, 2:36:07 PM9/20/10
to dbl...@googlegroups.com
On Sat, 2010-09-18 at 22:09 +1000, James Darbyshire wrote:
> According to this website
> (http://msdn.microsoft.com/en-us/library/bb386947.aspx) timestamp
> should be binary or byte[] type,

Where do you see that mapping? At:

http://msdn.microsoft.com/en-us/library/bb386947.aspx#DateMapping

I see that most types are mapped to DateTime, TimeSpan, or
DateTimeOffset. I don't see any mention of using Binary or byte[]
within DateTime mapping at all.

- Jon


James Darbyshire

unread,
Sep 20, 2010, 7:32:04 PM9/20/10
to dbl...@googlegroups.com
Hi Jon,

I found the mapping here --> http://msdn.microsoft.com/en-us/library/bb386947.aspx (same as yours) but it suggests in the graph and in the binary table (http://msdn.microsoft.com/en-us/library/bb386947.aspx#BinaryMapping) that timestamp is byte[] or binary.

The timestamp I am using is the MySQL timestamp data type, which maps to byte[] or binary.

Am I missing something?

James



--
You received this message because you are subscribed to the Google Groups "DbLinq" group.
To post to this group, send email to dbl...@googlegroups.com.
To unsubscribe from this group, send email to dblinq+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/dblinq?hl=en.

Jonathan Pryor

unread,
Sep 20, 2010, 10:36:20 PM9/20/10
to dbl...@googlegroups.com
On Tue, 2010-09-21 at 09:32 +1000, James Darbyshire wrote:
> I found the mapping here
> --> http://msdn.microsoft.com/en-us/library/bb386947.aspx (same as
> yours) but it suggests in the graph and in the binary table
> (http://msdn.microsoft.com/en-us/library/bb386947.aspx#BinaryMapping)
> that timestamp is byte[] or binary.

My apologies, I apparently misread "timestamp" as "datetime." I need to
check my reading comprehension. :-/

Anyway, the reason it's mapped to DateTime is because of
src/DbLinq/Vendor/Implementation/SchemaLoader.TypeMapping.cs
SchemaLoader.MapDbType():

case "timestamp":
// ...
return typeof(DateTime);

Alas, I don't know why this type was selected; the commit message
doesn't provide any help [0].

Looks like another case of i238 [1]/i271 [2]: DbLinq really shouldn't be
hard-coding these type mappings...

- Jon

[0] r934: Added uuid type support (for PostgreSQL)
[1] http://code.google.com/p/dblinq2007/issues/detail?id=238
[2] http://code.google.com/p/dblinq2007/issues/detail?id=271


James Darbyshire

unread,
Sep 21, 2010, 7:29:44 AM9/21/10
to dbl...@googlegroups.com

Thanks Jon. Always helpful!

Ok. Well for now it's not too hard to manually change datetime to byte[] in the designer.

Are there any plans to use mysql.data.dll to do the type mappings (as suggested on those bug reports) any time soon?

If not I may have a hack and submit the code.

Regards,

James Darbyshire

Sent from my Samsung Droid™

On 21/09/2010 12:36 PM, "Jonathan Pryor" <jonp...@vt.edu> wrote:

On Tue, 2010-09-21 at 09:32 +1000, James Darbyshire wrote:
> I found the mapping here

> --> http://m...

My apologies, I apparently misread "timestamp" as "datetime."  I need to
check my reading comprehension. :-/

Anyway, the reason it's mapped to DateTime is because of
src/DbLinq/Vendor/Implementation/SchemaLoader.TypeMapping.cs
SchemaLoader.MapDbType():

           case "timestamp":
           // ...
               return typeof(DateTime);

Alas, I don't know why this type was selected; the commit message
doesn't provide any help [0].

Looks like another case of i238 [1]/i271 [2]: DbLinq really shouldn't be
hard-coding these type mappings...

 - Jon

[0] r934: Added uuid type support (for PostgreSQL)
[1] http://code.google.com/p/dblinq2007/issues/detail?id=238
[2] http://code.google.com/p/dblinq2007/issues/detail?id=271



--

You received this message because you are subscribed to the Google Groups "DbLinq" group.

To post to...

Jonathan Pryor

unread,
Sep 21, 2010, 10:05:51 AM9/21/10
to dbl...@googlegroups.com
On Tue, 2010-09-21 at 21:29 +1000, James Darbyshire wrote:
> Are there any plans to use mysql.data.dll to do the type mappings (as
> suggested on those bug reports) any time soon?

I won't be working on it any time soon, as I'm swamped with other work.

If you decide to hack on it, you can look at
src/DbLinq.SqlServer/SqlServerSchemaLoader.cs for a base.

- Jon


James Darbyshire

unread,
Sep 21, 2010, 5:39:02 PM9/21/10
to dbl...@googlegroups.com

No worries Jon, I will let you know when I have had a look into it.

Thanks again, jd

Regards,

James Darbyshire

Sent from my Samsung Droid™

On 22/09/2010 12:05 AM, "Jonathan Pryor" <jonp...@vt.edu> wrote:

On Tue, 2010-09-21 at 21:29 +1000, James Darbyshire wrote:

> Are there any plans to use mysql.data.d...

I won't be working on it any time soon, as I'm swamped with other work.

If you decide to hack on it, you can look at
src/DbLinq.SqlServer/SqlServerSchemaLoader.cs for a base.

 - Jon



--

You received this message because you are subscribed to the Google Groups "DbLinq" group.

To post to this group, send email to dbl...@googlegroups.com.
To unsubscribe from this group, send e...

Reply all
Reply to author
Forward
0 new messages