views:

221

answers:

4

Hi

What is the best data type to choose in C# for representing a SQL Serer UniqueIdentifier type? I'm was going to use a GUID but I've seen people using varChars.

Thanks

+3  A: 

System.Guid is what you need.

You can learn about CLR equivalents of SQL data types in this article:

SQL Server Data Types and Their .NET Framework Equivalents

Developer Art
correct answer due to the helpful link also provided.
Davy
+2  A: 

GUID is the best choice.

Jamie Ide
Thanks - vote up
Davy
+4  A: 

Whenever I use a uniqueidentifier sql data type I always map it to a Guid in C#. I don't think I've ever seen it done differently.

Joseph
+1. People using varchars to represent GUIDs or strings to represent UNIQUEIDENTIFIER are using the *wrong type*.
Dave Markle
Thanks - vote up.
Davy
+1  A: 

GUID is the direct comparison.

Martin
Thanks - vote up
Davy