0
我使用AngularJS /微風,我需要用微風格式寫的(http://www.breezejs.com/documentation/query-examples)以下SQL:breezejs子查詢一個一對多的關係
SELECT * FROM聯繫WHERE ID IN(從pharmacy_contact其中pharmacy_id選擇CONTACT_ID =「11855」
我的模型類如下:
[Table("pharmacy_contact")]
public class PharmacyContact
{
[Key]
public int Id { get; set; }
public int? PharmacyId { get; set; }
public int? ContactId { get; set; }
}
[Table("contact")]
public class Contact
{
[Key]
public int Id { get; set; }
public string First_Name { get; set; }
public string Last_Name { get; set; }
public string Title { get; set; }
public string Phone { get; set; }
public string Extn { get; set; }
public string Fax { get; set; }
public string Email { get; set; }
public string Contact_Daytime { get; set; }
public string Contact_Method { get; set; }
public string Contact_Type { get; set; }
}
請讓我知道我應該怎麼寫上面的查詢在微風
我已經實現了上述的建議,但我得到一個錯誤: 「無法找到屬性:上的EntityType pharmacy_Contact:聯繫人:#AIE.Model查詢失敗「。我嘗試着遵循Angular/Breeze遵循的camelcasing慣例,但目前爲止還沒有人工作。請讓我知道我應該如何對此進行處理。 – user3153361
這是因爲你需要告訴EF有關FK的信息。在'pharmacy_contact'類中,在ContactId屬性前添加註釋'[ForeignKey(「Contact」)] –
添加FK後,我得到了上面提到的以下錯誤: {「類型'AIE.Model.Pharmacy_Contact'上屬性'ContactId'上的ForeignKeyAttribute無效。在依賴類型'AIE.Model.Pharmacy_Contact'上未找到導航屬性'contact'。應該是一個有效的導航屬性名稱。「} – user3153361