entity framework: join on the rule "A = substring(B)"?
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.
精彩评论