Skip to content

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

@jmkinzer

Description

@jmkinzer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions