neisbut / EntityFramework.MemoryJoin

Extension for EntityFramework for joins to in-memory data
MIT License
56 stars 24 forks source link

IBM.DB2 EF6 support #20

Closed raydenl closed 2 years ago

raydenl commented 3 years ago

We use DB2 at my place of work, I tried MemoryJoin but DB2 (or at least the version we use) uses underscores as conditional compilation directives, so the error displayed further down is thrown. Removing these from the front of the DynamicTableName string ("__gen_query_data" becomes "gen_query_data") seems to fix the issue! :)

My code doesn't hit param creation code using the "@__gen_qp" pattern, so can't tell if that would also be an issue. The QueryModelClass table and schema name also start with a double underscore, but that doesn't appear to cause a problem.

Error:
{
  "Message": "An error has occurred.",
  "ExceptionMessage": "An error occurred while executing the command definition. See the inner exception for details.",
  "ExceptionType": "System.Data.Entity.Core.EntityCommandExecutionException",

  "InnerException": {
    "Message": "An error has occurred.",
    "ExceptionMessage": "ERROR [428HV] [IBM][DB2/LINUXX8664] SQL20521N  Error occurred processing a conditional compilation directive near \"_\". Reason code=\"7\".",
    "ExceptionType": "IBM.Data.DB2.DB2Exception",
    "StackTrace": "   at IBM.Data.DB2.DB2Command.ExecuteReaderObject(CommandBehavior behavior, String method, DB2CursorType reqCursorType, Boolean abortOnOptValueChg, Boolean skipDeleted, Boolean isResultSet, Int32 maxRows, Boolean skipInitialValidation)\r\n   at IBM.Data.DB2.DB2Command.ExecuteReaderObject(CommandBehavior behavior, String method)\r\n   at IBM.Data.DB2.DB2Command.ExecuteReader(CommandBehavior behavior)\r\n   at IBM.Data.DB2.DB2Command.ExecuteDbDataReader(CommandBehavior behavior)\r\n   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)\r\n   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<>c.<Reader>b__6_0(DbCommand t, DbCommandInterceptionContext`1 c)\r\n   at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)\r\n   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)\r\n   at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)\r\n   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)\r\n   at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)"
  }
}
neisbut commented 3 years ago

Hi @raydenl, hm, I'm new to IBM.DB2, so I might be incorrect, I think you may try to use another schema and table name for QueryModelClass using fluent API. Kind of this:

modelBuilder.Entity<QueryModelClass>().ToTable("betterName", "schema");

Also now you can rename used parameters with the following code:

MemoryJoiner.ParametersPrefix = "@better_prefix_";