Skip to content

11G .net core 3.1 beta | linq query exception when relating classes  #71

@CoSMtnDog

Description

@CoSMtnDog

I was unable to reopen and I'm unsure if you get notifications so opening a new one for 11G. Apologies if I'm doing this wrong.

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production
PL/SQL Release 11.2.0.4.0 - Production
CORE 11.2.0.4.0 Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production

` public class DaleContext : DbContext
{
public DaleContext()
{
ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
}

public DaleContext(DbContextOptions options) : base(options)
{
  ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
}

public DaleContext(DbContextOptions<SecurityContext> options) : base(options)
{
  ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
}
public DbSet<BookingBlock> BookingBlocks { get; set; }
public DbSet<CustomerGroup> CustomerGroups { get; set; }

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
  //leaving this for now to use for direct db integration/validation in unit test
  if (!optionsBuilder.IsConfigured)
  {
    //if this does remain, then pull data source string from json file where it's NOT stored in git
    optionsBuilder
      .UseLoggerFactory(ConsoleLoggerFactory)
      .UseOracle("Data Source = xxxx;"
      , b => b.UseOracleSQLCompatibility("11"));
  }
}

public static readonly ILoggerFactory ConsoleLoggerFactory =
  LoggerFactory.Create(builder =>
  {
    builder.AddFilter((category, level) =>
      category == DbLoggerCategory.Database.Command.Name && level == LogLevel.Information).AddConsole();
  });

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
  modelBuilder.Entity<BookingBlock>().ToTable("PDF_BOOKING_BLOCK");
  modelBuilder.Entity<BookingLimit>().ToTable("PDF_BOOKING_LIMIT");
  modelBuilder.Entity<CustomerGroup>().ToTable("PDF_CUST_GROUP");

  //one to many
  modelBuilder.Entity<CustomerGroup>().HasMany(cg => cg.BookingBlocks).WithOne(bb => bb.CustomerGroup);

  //tables w/ composite keys
  modelBuilder.Entity<BookingBlock>()
      .HasKey(pk => new { pk.RPTNG_FLOW_PATH_ID, pk.CUST_GROUP_IDFTN });

}`

public class CustomerGroup { public CustomerGroup() { BookingBlocks = new List<BookingBlock>(); } [Key] public int CUST_GROUP_IDFTN { get; set; } public string CUST_GROUP_NAME { get; set; } public string CUST_GROUP_DESC { get; set; } public string ENABLED_INDIC { get; set; } public string LAST_CHNGD_IDFTN { get; set; } public DateTime DATE_CRTD { get; set; } public DateTime DATE_LAST_CHNGD { get; set; } public List<BookingBlock> BookingBlocks { get; set; } }

public class BookingBlock { public int RPTNG_FLOW_PATH_ID { get; set; } public int CUST_GROUP_IDFTN { get; set; } public int BLOCK_MIN_LEAD_TIME { get; set; } public int BLOCK_BKNG_WEEKS { get; set; } public string ENABLED_INDIC { get; set; } public int SORT_SEQ { get; set; } public string LAST_CHNGD_IDFTN { get; set; } public DateTime DATE_CRTD { get; set; } public DateTime DATE_LAST_CHNGD { get; set; } public CustomerGroup CustomerGroup { get; set; } }

1st test method

This test method used to work but after upgrade to 11G, it no longer does a simple count:
NOTE: When I comment out the fluent relationship and the CustomerGroup property from BookBlock, then the first test method works.
[TestMethod] public void GetBookBlockCountExample() { using (var context = new DaleContext()) { var bookingBlocks = context.BookingBlocks.ToList(); Console.WriteLine($"count {bookingBlocks.Count}"); } }

Exception for 1st test method

Message:
Test method Arconic.UnitTest.Core.DaleUnitTest.GetBookBlockCountExample threw exception:
Oracle.ManagedDataAccess.Client.OracleException: ORA-00904: "p"."CustomerGroupCUST_GROUP_IDFTN": invalid identifier
Stack Trace:
OracleConnectionImpl.VerifyExecution(Int32& cursorId, Boolean bThrowArrayBindRelatedErrors, SqlStatementType sqlStatementType, Int32 arrayBindCount, OracleException& exceptionForArrayBindDML, Boolean& hasMoreRowsInDB, Boolean bFirstIterationDone)
OracleCommandImpl.ExecuteReader(String commandText, OracleParameterCollection paramColl, CommandType commandType, OracleConnectionImpl connectionImpl, OracleDataReaderImpl& rdrImpl, Int32 longFetchSize, Int64 clientInitialLOBFS, OracleDependencyImpl orclDependencyImpl, Int64[] scnForExecution, Int64[]& scnFromExecution, OracleParameterCollection& bindByPositionParamColl, Boolean& bBindParamPresent, Int64& internalInitialLOBFS, OracleException& exceptionForArrayBindDML, OracleConnection connection, OracleLogicalTransaction& oracleLogicalTransaction, IEnumerable1 adrianParsedStmt, Boolean isDescribeOnly, Boolean isFromEF) OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior) OracleCommand.ExecuteDbDataReader(CommandBehavior behavior) DbCommand.ExecuteReader() OracleRelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject) Enumerator.InitializeReader(DbContext _, Boolean result) OracleExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func3 verifySucceeded) Enumerator.MoveNext() List1.ctor(IEnumerable1 collection) Enumerable.ToList[TSource](IEnumerable1 source)
DaleUnitTest.GetBookBlockCountExample() line 29

This is the test method I used w/ 10G and it responds the same in 11G. Could it be the composite key of the child class BookBlock?

2nd test method

[TestMethod] public void Get_AmCastleCompany_FlowPath_27NFT_BookingWeeks() { //relationships not working in 10G because ODP using (var context = new DaleContext()) { var customer = context.CustomerGroups.Where(cg => cg.CUST_GROUP_IDFTN == 275 && cg.BookingBlocks.FirstOrDefault().RPTNG_FLOW_PATH_ID == 2).ToList(); Assert.AreEqual(1, customer.Count); } }

The exception for 2nd test method:

Message:
Test method Arconic.UnitTest.Core.DaleUnitTest.Get_AmCastleCompany_FlowPath_27NFT_BookingWeeks threw exception:
Oracle.ManagedDataAccess.Client.OracleException: ORA-00904: "p0"."CustomerGroupCUST_GROUP_IDFTN": invalid identifier
Stack Trace:
OracleConnectionImpl.VerifyExecution(Int32& cursorId, Boolean bThrowArrayBindRelatedErrors, SqlStatementType sqlStatementType, Int32 arrayBindCount, OracleException& exceptionForArrayBindDML, Boolean& hasMoreRowsInDB, Boolean bFirstIterationDone)
OracleCommandImpl.ExecuteReader(String commandText, OracleParameterCollection paramColl, CommandType commandType, OracleConnectionImpl connectionImpl, OracleDataReaderImpl& rdrImpl, Int32 longFetchSize, Int64 clientInitialLOBFS, OracleDependencyImpl orclDependencyImpl, Int64[] scnForExecution, Int64[]& scnFromExecution, OracleParameterCollection& bindByPositionParamColl, Boolean& bBindParamPresent, Int64& internalInitialLOBFS, OracleException& exceptionForArrayBindDML, OracleConnection connection, OracleLogicalTransaction& oracleLogicalTransaction, IEnumerable1 adrianParsedStmt, Boolean isDescribeOnly, Boolean isFromEF) OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior) OracleCommand.ExecuteDbDataReader(CommandBehavior behavior) DbCommand.ExecuteReader() OracleRelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject) Enumerator.InitializeReader(DbContext _, Boolean result) OracleExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func3 verifySucceeded) Enumerator.MoveNext() List1.ctor(IEnumerable1 collection) Enumerable.ToList[TSource](IEnumerable1 source)
DaleUnitTest.Get_AmCastleCompany_FlowPath_27NFT_BookingWeeks() line 62

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions