EDM.Boolean is mapped to the BYTEINT Teradata type. Refer to Data Type Mapping for more information on Boolean to Teradata type mapping within the Entity Provider for Teradata.
When a parameter represents a boolean, the value of the parameter can be one of the following:
The Entity Provider for Teradata translates a true as 1 and a false as 0.
The Entity Framework will allow the value of a parameter to be set to Integer values other than 0 or 1. It is highly recommended that applications only use the 4 listed values to avoid any confusion. Specifying a value other than one of the listed four will cause the Entity Provider to behave unexpectedly. This is demonstrated in the following Entity Sql example:
Entity Provider Parameter Example 1 |
Copy Code |
---|---|
public void EntityProviderParameterExample1() { // Setting up the connection string to the data provider TdConnectionStringBuilder tbuilder = new TdConnectionStringBuilder(); tbuilder.Database = "Database"; tbuilder.DataSource = "Source"; tbuilder.UserId = "user"; tbuilder.Password = "password"; EntityConnectionStringBuilder ebuilder = new EntityConnectionStringBuilder(); // Setting up the connection for the Entity Framework ebuilder.Metadata = @"res://Example/EDMExample.csdl|res://Example/EDMExample.msl|res://Example/EDMExample.ssdl"); ebuilder.Provider = "Teradata.Client.Provider"; ebuilder.ProviderConnectionString = tbuilder.ToString(); EntityConnection eConn = new EntityConnection(ebuilder.ToString()); eConn.Open(); EntityCommand eCmd = eConn.CreateCommand(); eCmd.CommandText = "select o from Orders as o where ((o.Freight * 2) > 100.00m) == @param1"; eCmd.Parameters.Add("param1", DbType.Boolean); // Value can also be set to 1 eCmd.Parameters[0].Value = true; EntityDataReader eDr = eCmd.ExecuteReader(CommandBehavior.SequentialAccess); // Retrieving the data of the properties foreach(var result in query) { // Process each record returned } } |
In this example the Value of the parameter has been set to true --it could have also be set to 1. For every row where the condition:
(o.Freight * 2) > 100.00m
is true the row is returned to the application. A similar behavior occurs if the Value of the parameter is set to false or 0. However, if the Value were set to an Integer other than 0 or 1, the condition:
((o.Freight * 2) > 100.00m) == @param1
can never be true. Therefore, no rows will be returned to the application. The reason for this is that the Entity Provider expects the condition:
(o.Freight * 2) > 100.00m
to only return a 1 for true or 0 for false. Therefore, if the Value of the parameter is not one of the four recommended values, the WHERE clause will always evaluate to false.