Guid.ToString() in Linq query?
c#, linq, sql
Solution
Switch your logic around and convert the `LinkGuid` paramter to a Guid:
private string getFileLocation(string LinkGuid)
{
try
{
Guid search = Guid.Parse(LinkGuid);
ISESEntities context = new ISESEntities();
string query = (from f in context.tbFileAttachments
where f.CCCPGUID == search
select f.FileLocation).First();
return query;
}
catch(Exception e)
{
blah blah
}
}
Problem
I have a method which attempts to pull a record from my db with a simple where clause. I have an issue because I'm passing in a string value and matching it to a Guid (uniqueIdentifier). I need the passed value as a string to bind in a DataGrid and I need the method to return a string. Obviously at run time, LinQ can't compile the query. The `.ToString()` method cannot be compiled into SQL. Any ideas? ``` private string getFileLocation(string LinkGuid) { try { ISESEntities context = new ISESEntities(); string query = (from f in context.tbFileAttachments where f.CCCPGUID.ToString() == LinkGuid select f.FileLocation).First(); return query; } catch(Exception e) { blah blah } } ```