question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

10G .net core 3.1 beta | linq query exception when relating classes

See original GitHub issue

It appears to exclude the dot between BookingBlock alias class and the property.

I’ve tweaked my classes and now I get a 00936 Missing expression. Update: I’ve added the one to many relationship in dbcontext and added the CustomerGroup as a property to BookingBlock. I get the same ora 00936.

The query I’m looking to mimic is select pbb.RPTNG_FLOW_PATH_ID, pcg.CUST_GROUP_IDFTN from PDF_BOOKING_BLOCK pbb, PDF_CUST_GROUP pcg where 1 = 1 and pbb.CUST_GROUP_IDFTN = pcg.CUST_GROUP_IDFTN and pbb.RPTNG_FLOW_PATH_ID = 2 and pbb.CUST_GROUP_IDFTN = 275

DBContext ` public DbSet<BookingLimit> BookingLimits { get; set; } public DbSet<BookingBlock> BookingBlocks { get; set; } public DbSet<CustomerGroup> CustomerGroups { get; set; } public DbSet<FlowPath> FlowPaths { 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) { optionsBuilder .UseLoggerFactory(ConsoleLoggerFactory) .UseOracle(“Data Source = xxx”); } }

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<FlowPath>().ToTable("PDF_FLOW_PATH");
  modelBuilder.Entity<CustomerGroup>().ToTable("PDF_CUST_GROUP");

  //tables w/ composite keys
  modelBuilder.Entity<BookingBlock>()
      .HasKey(pk => new { pk.RPTNG_FLOW_PATH_ID, pk.CUST_GROUP_IDFTN }); 
  //one to many
  modelBuilder.Entity<CustomerGroup>().HasMany(cg => cg.BookingBlocks).WithOne(bb => bb.CustomerGroup);

`

Classes

` 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 FlowPath FlowPath { get; set; }

public CustomerGroup CustomerGroup { get; set; } } `

on 06/02 I got this error. Oracle.ManagedDataAccess.Client.OracleException: ORA-00904: “p”.“BookingBlockCUST_GROUP_IDFTN”: invalid identifier

After some class adjustments I now get the 00936 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); }

Test method Oracle.ManagedDataAccess.Client.OracleException: ORA-00936: missing expression

I have no issues running this the filter w/ just the cust identifer: ` using (var context = new DaleContext()) { var customer = context.CustomerGroups.Where(cg => cg.CUST_GROUP_IDFTN == 275).ToList(); customer.ForEach(c => Console.WriteLine(c.CUST_GROUP_NAME));

    Assert.AreEqual(1, customer.Count);
  }

`

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
alexkehcommented, Jun 3, 2020

@JQ-IOWA My team at Oracle hasn’t tested Oracle 10.2 DBs with Oracle EF Core 3.1 since it’s not a supported combination. It’s not totally unexpected that some straightforward use cases will fail.

1reaction
alexkehcommented, Jun 3, 2020

Yes, please re-open if it fails with DB 11.2.0.4 or higher.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgraded to .NET Core 3.1 and receiving an error in a ...
You have alot of FirstOrDefault (s) calls. To code them "safely", you can try this: .FirstOrDefault() ?? string.Empty.
Read more >
Handle exceptions in query expressions (LINQ in C#)
This example shows how to avoid raising exceptions when you call methods in a query expression without violating the general .NET guidelines ...
Read more >
New features in Entity Framework Core 3.x - EF Core
The following list includes the major new features in EF Core 3.x ... LINQ enables you to write database queries using your .NET...
Read more >
LINQPad 6 - Release Notes
LINQPad 6 requires .NET Core 3.1 or .NET 5. You can get this in any of the following ways: Run the LINQPad 6...
Read more >
Writing Better Performing Queries with LINQ on EF Core 6.0 ⚙️
With LINQ, a query is a first-class language construct, just like classes, methods, events. You write queries against strongly typed collections of objects...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found