I am currently trying to check if there exists an instance of an object with a unique ID in a SQL Table. So as to not place duplicates. Here is a sample of what I currently have:
string ui = someObj.getUniqueID();
IQueryable<String> checkDataQuery = from cdq in db.SomeObjects
where cdq.UniqueID == ui
select cdq.UniqueID;
if (checkDataQuery != ui) // This is just my attempt at making sure that
// the query actually returned something and not
// the string representing nothing found, so if there
// is a better checking method that would even more helpful.
The main issue I am running into is that I can not access checkDataQuery as a string. I attempted casting it, and using the .Single()/.First() methods, however, the former had no success, and the latter made the single string being returned into a list of characters.