我有以下的亞音速3.0的查詢,其中包含嵌套NotIn查詢:Subsonic 3 ActiveRecord嵌套選擇的NotIn錯誤?
public List<Order> GetRandomOrdersForNoReason(int shopId, int typeId)
{
// build query
var q = new SubSonic.Query.Select().Top("1")
.From("Order")
.Where("ShopId")
.IsEqualTo(shopId)
.And(OrderTable.CustomerId).NotIn(
new Subsonic.Query.Select("CustomerId")
.From("Customer")
.Where("TypeId")
.IsNotEqualTo(typeId))
.OrderDesc("NewId()");
// Output query
Debug.WriteLine(q.ToString());
// returned typed list
return q.ExecuteTypedList<Order>();
}
內部查詢似乎是不正確的:
SELECT TOP 1 *
FROM [Order]
WHERE ShopId = @0 AND CustomerId NOT IN (SELECT CustomerId
FROM [Customer]
WHERE TypeId = @0)
ORDER BY NewId() ASC
你會發現,這兩個參數是@ 0。我假設參數是枚舉(從零開始),爲每個「新」選擇查詢。但是,在兩個Select查詢嵌套的情況下,我預料輸出會有兩個參數,分別命名爲@ 0和@ 1。
我的查詢基於one是羅布科納介紹了他的博客爲「Pakala」查詢工具,成爲亞音速3.他的榜樣的預覽是:
int records = new Select(Northwind.Product.Schema)
.Where("productid")
.In(
new Select("productid").From(Northwind.Product.Schema)
.Where("categoryid").IsEqualTo(5)
)
.GetRecordCount();
有其他人看到這種行爲?這是一個錯誤,或者這是一個錯誤還是我的一部分?由於我是Subsonic的新手,我猜這可能是程序員錯誤,但我希望儘可能確認。