iqtoolkit
iqtoolkit copied to clipboard
database column name differing from member name leads to incorrect query
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