0
這一件簡單的SQL的工作在SQL Server的完美......EntityDataSource的CommandText計數錯誤
Select it.Id as Id, it.Status as Status,
(SELECT COUNT (*) FROM PickLocations as pl WHERE pl.PickBatchItemId = bi.Id) AS Counts
FROM PickBatches AS it
INNER JOIN PickBatchItems as bi ON it.Id = bi.PickBatchId
給我...
Id, Status, Counts
-------------------
1 1 2
2 1 0
3 2 2
但作出變化,所以不會抱怨了。 ..
Select it.Id as Id, it.Status as Status,
(SELECT COUNT (pl.Id) FROM PickLocations AS pl WHERE bi.Id == pc.PickBatchItemId) AS Count
FROM PickBatches AS it
INNER JOIN PickBatchItems as bi ON it.Id == bi.PickBatchId
當我使用這個在EntityDataSource CommandText中我得到...
Id, Status, Counts
-------------------
1 1 System.Collections.Generic.List`1[System.Data.Common.DbDataRecord]
2 1 System.Collections.Generic.List`1[System.Data.Common.DbDataRecord]
3 2 System.Collections.Generic.List`1[System.Data.Common.DbDataRecord]
顯然,簡單的東西...
UPDATE
問題由維克拉姆解決。
使用select 值計數()並獲得計數值的指數與計數[0]
我記得那個試圖和我 - System.Data.Objects.MaterializedDataRecord – Luckyl337 2012-03-09 11:51:56
你能告訴我你在哪裏使用計數的代碼[0]?我已經編輯了我的答案 – Vikram 2012-03-09 12:03:03
我正在使用一個ListView並在一個Lable中進行綁定,像這樣 - 「/> –
Luckyl337
2012-03-09 12:32:41