Sunday, April 06, 2008

In my previous post (LINQ to SQL in multi layered + service apps), I mentioned how LINQ to SQL can be used in WCF apps but how to you deal with concurrency checking?  One way is to use a Timestamp column in your tables.  This is a binary type so how will WCF deal with that?

LINQ to SQL maps the SQL Timestamp type to the System.Data.Linq.Binary type.  If you add a DataMember attribute to a System.Data.Linq.Binary field, it will work.  WCF will not choke on that.  So what does the client sees?  Something like this: Service1.Binary.

This whole thing may leads to a few problems:

  1. Binary stuff is not very interoperable
  2. Service1.Binary != System.Data.Linq.Binary

One solution is to convert the info from Binary to String.  Andrew Siemer posted a couple of extension methods that allow you to do just that.  Check it out:
http://geekswithblogs.net/AndrewSiemer/archive/2008/02/11/converting-a-system.data.linq.binary-or-timestamp-to-a-string-and-back.aspx

Simple and easy and you can convert the data right into your LINQ to SQL queries.

 

Sunday, April 06, 2008 8:00:48 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 
All comments require the approval of the site owner before being displayed.
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Live Comment Preview

Theme design by Jelle Druyts