LINQ to SQL FAQ – mapping functions and methods

When trying to write a LINQ to SQL query you have to be mindful of what is supported as a translation from VB/C# into SQL. For example you can specify somestring.Trim() and this is translated into LTRIM(RTRIM(SOMESTRING)).

A lot of the time a suck-it-and-see approach is okay, but it can introduce runtime errors into programs. Fortunately there is a reference guide to help at 

One interesting find here is the SQLmethods class. This allows you to perform specific SQL methods that have no direct translation from CLR into LINQ to SQL.

Most of these are DateDiff computations, to permit you to compute the differences between two date values directly in SQL.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s