The Advanced SQL Engine does not support the APPLY operator. If the Entity Provider for Teradata detects that an APPLY operator is contained in the information generated by the Entity Framework a NotSupportedException will be thrown. There are two ways the information sent by the Entity Framework will include an APPLY operator:
Specifying an APPLY operator in an Entity Sql statement. The Entity Framework will indicate that an APPLY operator is to be used in the information passed to the Entity Provider.
An application is unable to specify an APPLY operator using LINQ to Entities.
When the Entity Framework is processing a LINQ to Entities or Entity Sql statement it may determine that an APPLY operator is needed. Unfortunately, there is no common pattern that will always cause the Entity Framework to specify an APPLY operator. Whether the framework specifies an APPLY is dependent on the EDM being used, and the statement being processed. However, Microsoft does list some typical scenarios that might lead to an APPLY operator being specified: Known Issues in SqlClient for Entity Framework: CROSS and OUTER APPLY Operators.
The following LINQ to Entities statement will cause the Entity Framework to specify an APPLY operator is to be used in the SQL statement generated by the Entity Provider for Teradata:
Apply Example |
Copy Code |
---|---|
public void ExampleApply() { // 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(); EDMExample context = new EDMExample(ebuilder.ToString()); var query = from o in context.Orders group o by o.ShipRegion into region select new { cust = region.Key, HighestFreightCharge = from o2 in region where o2.Freight == region.Max (o3 => o3.Freight) select o2 } // Executing the LINQ statement foreach(var record in query) { // Process each record returned } } |