Adam Rackis
Adam Rackis

Reputation: 83358

Case Insensitive Entity Keys

I've got a view vwCountyStateJurisdiction with columns:

State varchar(2) PK
County varchar(20) PK
Jurisdiction varchar(20) PK
JurisdictionName varchar(100)

(those keys are not on the view, but rather added to the entity in EF)

In EF, I'm trying to add an association from the Property table, to this view. I add the referential constraint, map properties from the Property table over to the three key fields in the view, and attempt to query. The problem is, those string keys are case sensitive when a property tries to load its related view object. When the case matches, it loads fine, otherwise I get nulls.

Is there ANY way to get this to be case insensitive?

Needless to say changing the database is not an option.

Thanks

Upvotes: 0

Views: 549

Answers (1)

Devart
Devart

Reputation: 121912

You can try the following approach, but note that it is rather work- and time-consuming.
Create DefiningQuery for each entity that has primary key that should be compared in case insensitive way. These queries should return the Upper(keycolumn) instead of keycolumn (the same for the dependent entities).
Please note that this approach remains read only until you create a set of stored procedures for insert, update and delete for each entity you have defined a query for.

Upvotes: 1

Related Questions