Entity Framework and String Key Associations

I am new to Entity Framework and ORM for this. In the project in which I am included, we have an outdated database, with all its keys as strings, case insensitive.

We convert to MSSQL and want to use EF as ORM, but we have encountered a problem.

Here is an example illustrating our problem:

Table A has a primary string key. Table B has a link to this primary key.

In LINQ we write something like:


var result = from t in context.TableB select t.TableA;
foreach( var r in result )
    Console.WriteLine( r.someFieldInTableA );  

if TableA contains the primary key that reads "A", and TableB contains two rows that refer to TableA, but with different cases in the link field: "a" and "A".

In our project, we want both lines to fall into the result, but only one with a suitable case will end there.

SQL Profiler, , .

Entity Framework, ?

:
NHibernate , NHibernate . , NHibernate .
, , Entity Framework.


!

, , - , . , , EF. , , .


,

edit: , , , , , , . .

+3
5

, SQL Server, EF. , , , , : T-SQL: , ?

+4

, , LINQ . EF , .Designer.cs objA.Equals(objB) ..Equals .

var = t1 . TableB join t2 . TableA t1.someFieldInTableB.ToUpper() t2.someFieldInTableA.ToUpper();

Hackish , LINQ to Entities , , , , , .

T4. , , , .

, , " " EF , .

+2

, , LINQ . EF    , .Designer.cs objA.Equals(objB) β†’ join..Equals .

, Equals

EF ? , Equals (, , )

BTW: , .NET 1.0

.NET 3.5/4.0, Linq Lambda

0

, "" ​​ , (: . [EntityTypeCollection]. fooobar.com/questions/584063/...

0

Entity Framework LINQ to SQL, , , . ORM EF NHibernate, .

I recently posted a thread on the official Microsoft Entity Framework forum: http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/d4aa6880-31b3-4ff2-b7f5-e2694d76772e

-1
source

Source: https://habr.com/ru/post/1705976/


All Articles