Reputation: 2076
When working with uniqueidentifier
from the database. Most of the time I just need it for comparison purposes in LINQ queries, and as value of HyperLink
's NavigateUrl
and similar situations. So, is it safe/feasible to treat uniqueidentifier
as string rather than System.Guid
for comparison purposes?
Upvotes: 0
Views: 67
Reputation: 100620
Yes, but it requires more careful coding than comparing Guids.
Code that uses Guid
for comparison is easier to get correct as there is exactly one representation of unique Guid
value in that form.
String representation is way more flexible (i.e. case, dashes) so you may need to either normalize values first (i.e. lower-case and remove all non-alphanumeric characters), or have custom comparator (i.e. one that only compares alphanumeric characters and ignores case).
Upvotes: 1