Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

database column name differing from member name leads to incorrect query #32

Open
jmkinzer opened this issue Sep 9, 2024 · 0 comments

Comments

@jmkinzer
Copy link

jmkinzer commented Sep 9, 2024

Please note this applies to the modern branch.

Minimal example based on the Northwind tests. This leads to the association between the tables being lost and so the resultant SQL lacks the where exists clause.

var res = someProvider.GetTable<Customer>().Select(c => new { c.CustomerID, c.Orders });
var qp = someProvider.GetQueryPlan(res.Expression);
Console.WriteLine(qp.QueryText);

[Table(Name = "Customers")]
public class Customer
{
    //[Column(Name = "CustomerID")] ok
    [Column(Name = "CustomerID1")]
    public string CustomerID;

    [Association(KeyColumns = nameof(CustomerID))]
    public List<Order> Orders;// = new List<Order>();
}

[Table(Name = "Orders")]
public class Order
{
   //[Column(Name = "CustomerID")] ok
    [Column(Name = "CustomerID1")]
    public string CustomerID;
}

Result:

SELECT t0."CustomerID1"
FROM "Customers" AS t0

SELECT t0."CustomerID1"
FROM "Orders" AS t0
@jmkinzer jmkinzer changed the title database column name differing member names from leads to incorrect query database column name differing from member name leads to incorrect query Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant