7

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

Thanks

4 Answers 4

10

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

Sign up to request clarification or add additional context in comments.

Comments

7

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.

1 Comment

+1. People using varchars to represent GUIDs or strings to represent UNIQUEIDENTIFIER are using the wrong type.
4

GUID is the best choice.

Comments

3

GUID is the direct comparison.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.