【问题标题】:ESQL does not workESQL 不工作
【发布时间】:2013-03-07 23:43:38
【问题描述】:

我正在开发 WCF、实体框架、自跟踪解决方案。

我的 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文件下,&lt;EntityType Name="AccHosp"&gt;下有&lt;property Name="achAccID" Nullable="false" Type="int"&gt;

那么真正的问题是什么?

【问题讨论】:

  • 您需要使用 ESQL 而不是 Linq 的任何具体原因?
  • 我认为名字是区分大小写的,所以h.achAccID可能应该是h.achAccId,如sql语句的末尾所示。
  • 我查过了,不是问题。

标签: c# entity-framework entity-sql


【解决方案1】:

ESQL 没有问题。数据上下文需要刷新。 IE。 db.Refresh(RefreshMode.StoreWins, db.AccHosps);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-01-02
    • 1970-01-01
    • 2013-07-29
    • 1970-01-01
    • 2017-01-18
    • 1970-01-01
    • 2016-05-07
    • 2016-10-10
    相关资源
    最近更新 更多