Cannot use a subclass of the DevArt OracleConnection
Description
We derived from the DevArt OracleConnection to add some functionality. However EF+ batch functions without a table name specified, are throwing exceptions. That is because the EntityContainerEntitySet.GetDestinationTableName function only investigates the top-level type of the DbConnection object. Is it possible to make it more flexible to investigate the type hierarchy? Something like: `public static class Program { public static void Main() { using (var connection = new DerivedOracleConnection(ConfigurationManager.ConnectionStrings["Default"].ConnectionString)) { if (GetTypeHierarchy(connection).Any(type => type.Name == "OracleConnection")) { // ... } } }
private static IEnumerable<Type> GetTypeHierarchy(object o)
{
var type = o?.GetType();
while (type != null)
{
yield return type;
type = type.BaseType;
}
}
}
public class DerivedOracleConnection : Devart.Data.Oracle.OracleConnection { public DerivedOracleConnection(string connectionString) : base(connectionString) { } }`
Exception
Exception message:
System.Exception
HResult=0x80131500
Message=Oops! The destination table name could not be found. That typically happens for an unsupported provider. If you use a custom connection, contact us to learn how to set it up within our library. Please report the issue to our support team : [email protected]
Source=Z.EntityFramework.Extensions
StackTrace:
at Z.EntityFramework.Extensions.Core.SchemaObjectModel.EntityContainerEntitySet.GetDestinationTableName(DbContext context, String databaseName, String schemaName)
at `1.()
at `1.Execute(IQueryable`1 query, String databaseName, String schemaName, String tableName, Expression`1 selectFieldsExpression, Type tableType)
at DbContextExtensions.[](IQueryable`1 , String , String , String , Expression`1 , Type )
at DbContextExtensions.InsertFromQuery[TEntity](IQueryable`1 query, Expression`1 selectFieldsExpression)
at TestConsoleApplication.Program.Main() in C:\local\TestConsoleApplication\TestConsoleApplication\Program.cs:line 12
Fiddle or Project
Included my test project. The connection string is of course changed. TestConsoleApplication.zip
Further technical details
- EF version: 6.4.4 (6.3 has the same issue)
- EF Plus version: 4.0.96
- Database Provider: Devart.Data.Oracle
Hello @citypermit ,
Thank you for reporting.
We will look at it
Best Regards,
Jon
Performance Libraries
context.BulkInsert(list, options => options.BatchSize = 1000);
Entity Framework Extensions • Entity Framework Classic • Bulk Operations • Dapper Plus
Runtime Evaluation
Eval.Execute("x + y", new {x = 1, y = 2}); // return 3
C# Eval Function • SQL Eval Function