views:

257

answers:

1

I have a non-primary-key column with GUID's (with DataType System.Guid) and it appears you cant use DataTable.Select on that column. (Only DataRowCollection.Find but it requires GUID to be Primary Key column, which is not my case)

Anyway, I need to get that row WHERE UniqueId = *GUID*

Maybe there are some LINQ tricks that can do the job?

A: 

You could try something like this:

C#:

var filteredRows = from dtr in yourDataTable.Rows
                   where ((System.Guid)dtr["MyGuidColumn"]) == myFilterGuid
                   select dtr;

VB:

Dim filteredRows = From dtr In yourDataTable.Rows _
                   Where DirectCast(dtr("MyGuidColumn"), System.Guid) = myFilterGuid _
                   Select dtr
Adam Maras
Great. Thank you :)
Janis Veinbergs