我有一個EDMX數據存儲和我試圖針對它執行存儲過程:實體框架的存儲過程 - 繪製複雜性
.
.
.
CustomerDb.ExecuteStoreQuery<Customer>("GetCustomers", parameters).ToList();
Customer類具有以下結構
class Customer {
public int Id { get; set; }
.
.
.
public Address Address { get; set; }
}
class Address {
public int Id { get; set; }
.
.
.
public string PostCode { get; set; }
}
現在不管我做什麼,Address
屬性始終爲空。我試圖以不同的格式返回結果集,但不管我做什麼,它總是空的。
E.g.
SELECT c.Id, ..., a.PostCode
FROM Customer AS c
INNER JOIN Address AS a ON c.CustomerId = a.CustomerId
WHERE c.CustomerId = @CustomerId
或
SELECT c.Id, ..., a.PostCode AS 'Address.PostCode'
FROM Customer AS c
INNER JOIN Address AS a ON c.CustomerId = a.CustomerId
WHERE c.CustomerId = @CustomerId
或
SELECT c.Id, ..., a.PostCode AS 'Address_PostCode'
FROM Customer AS c
INNER JOIN Address AS a ON c.CustomerId = a.CustomerId
WHERE c.CustomerId = @CustomerId
但列永不回升。
我在做什麼錯?
謝謝。
啊。感謝那! – Umair 2013-05-10 15:39:35