Export (0) Print
Expand All

Basic Data Types

Because LINQ to SQL queries translate to Transact-SQL before they are executed on the Microsoft SQL Server. LINQ to SQL supports much of the same built-in functionality that SQL Server does for basic data types.

Implicit or explicit casts are enabled from a source CLR type to a target CLR type if there is a similar valid conversion within SQL Server. For more information about CLR casting, see CType Function (Visual Basic) (Visual Basic) and as (C# Reference). After conversion, casts change the behavior of operations performed on a CLR expression to match the behavior of other CLR expressions that naturally map to the destination type. Casts are also translatable in the context of inheritance mapping. Objects can be cast to more specific entity subtypes so that their subtype-specific data can be accessed.

LINQ to SQL supports the following equality operators on basic data types inside LINQ to SQL queries:

  • Equal and Inequality Operator: Equality and inequality operators are supported for numeric Boolean, DateTime, and TimeSpan types. For more about Visual Basic operators = and <>, see Comparison Operators (Visual Basic). For more information about C# comparison operators == and !=, see == Operator (C# Reference) and != Operator (C# Reference), respectively 

  • Is operator: The IS operator has a supported translation when inheritance mapping is being used. It can be used instead of directly testing the discriminator column to determine whether an object is of a specific entity type, and is translated to a check on the discriminator column. For more information about the Visual Basic and C# Is operators, see Is Operator (Visual Basic) and is (C# Reference).

Show:
© 2014 Microsoft