LINQEntityGUID has no supported translation to SQL

Nov 11, 2009 at 2:54 PM
Edited Nov 11, 2009 at 2:55 PM

All --

Please help.

I am getting a run-time-error (RTE) of "LINQEntityGUID has no supported translation to SQL" when I have a gridview as with allowsorting="true" and autogeneratecolumns="true", such as...

<asp:gridview id="MainGridView" runat="server" allowsorting="True" autogeneratecolumns="True" datakeynames="PkId" datasourceid="MasterLinqDataSource" emptydatatext="NULL" onselectedindexchanged="MainGridView_SelectedIndexChanged" onsorted="MainGridView_Sorted" pagesize="20">

...which generates a column for "LINQEntityGUID" which, when clicked for sorting, throws the RTE...

The member 'Team.Wxyz.BusinessLayer.BusinessEntities.LINQEntityBase.LINQEntityGUID' has no supported translation to SQL.

...which is sad for me.

(I need to autogenerate columns because this is a generic component.)

Do you know of a way to fix this?

Is not the LINQEntityGUID simply a Guid at heart?

What do you think?

Please advise.

Thank you.

-- Mark Kamoski

Nov 11, 2009 at 7:56 PM


LINQEntityGuid is nothing but a GUID, there's nothing special about it.

You are getting that error because LINQ to SQL doesn't know how to deal with it, because it's not a LINQ to SQL attribute column, but the data grid doesn't know this.

In order to avoid this, the only thing I can think of is to change the linq statement (data source) you use to bring everthing into memory/session, so that it doesn't refer back to the db for the sort  (if this is appropriate, depending on the length of your result set, paging etc)

For example, where you have:

from a in apples

select a;

change it to:

from a in apples.ToEnumerable()

select a;

and cache the results in the session object, to use for retrieval.