开发者

entity framework: join on the rule "A = substring(B)"?

开发者 https://www.devze.com 2023-03-05 04:02 出处:网络
Could I ask somebody show me the way how to declare the association between two entities \'Record\' and \'DictionaryItem\' if corresponded tables on the DB level are joinedby such interesting rule:

Could I ask somebody show me the way how to declare the association between two entities 'Record' and 'DictionaryItem' if corresponded tables on the DB level are joined by such interesting rule:

FROM Records R LEFT OUTER JOIN DictionaryItems D 
  ON SUBSTRING(R.Compos开发者_Python百科iteKey,3,8) = D.DictionaryItemId

P.S. I'm now working with POCO entities.


Linq-to-entities doesn't support Substring. You must either execute SQL directly by calling context.Database.SqlQuery<> or you must use Entity SQL - that would probably require converting DbContext to ObjectContext via IObjectContextAdapter, creating ObjectSet and running ESQL query.

0

精彩评论

暂无评论...
验证码 换一张
取 消