2013-03-07 10 views
2

我正在研究WCF,實體框架,自我跟蹤解決方案。ESQL不起作用

我遇到了ESQL問題。

string cmd = "Select h.achAccId, p.patDOBirth, p.patGender from PatientEntities.AccBases as a, PatientEntities.AccHosps as h, PatientEntities.Patients as p Where h.achAccID = 57348 and p.patPatId = a.acbPatId and h.achAccId = a.acbAccId"; 


ObjectQuery<dbdatarecord>queryResult = null; 

using (PatientEntities db = new PatientEntities()) PatientEntities is ObjectContext 
{ 
    `queryResult = db.CreateQuery<dbdatarecord>(cmd);` 
} 

if ((queryResult != null) && (queryResult.Count() > 0)) 
{ 
    `...` 
} 

queryResult.Count()導致錯誤:「‘achAccID’不是類型的成員‘PatientModel.AccHosp’在當前加載模式」

我下PatientModel.edmx文件中找到,<EntityType Name="AccHosp">下有<property Name="achAccID" Nullable="false" Type="int">

那真正的問題是什麼?

+1

您需要使用ESQL而不是Linq的任何原因? – Pawel 2013-03-08 00:15:41

+0

我認爲名稱是區分大小寫的,所以'h.achAccID'可能應該是''''''''''''''''''''''''''' – 2013-03-08 00:43:03

+0

我檢查過,這不是問題。 – peter 2013-03-10 22:39:30

回答

0

ESQL沒有問題。 datacontext需要刷新。即。 db.Refresh(RefreshMode.StoreWins,db.AccHosps);