LINQ to Entities does not return the expected result

I use the view to return a complex search query. When I use linq to query EF, it returns the same string 3 times (the actual string is correct).

using LinqPad I performed the same linq against my ef object and the actual database view.

ReadmitPatientList
    .AsQueryable()
    .Where("PatientLastName.StartsWith(\"cooper\")")
    .OrderBy (rpl => rpl.PatientLastName)
    .Dump();

This is linq, which I use for both.

linqpad shows lambda as follows: EF:

ReadmitPatientList.MergeAs (AppendOnly)
   .Where ( => .PatientLastName.StartsWith ("cooper"))
   .OrderBy (rpl => rpl.PatientLastName)

Db

ReadmitPatientList
   .Where ( => .PatientLastName.StartsWith ("cooper"))
   .OrderBy (rpl => rpl.PatientLastName)

I cannot post the results ... but EF returns three rows of the same record. DB returns 3 rows of individual records. Like my sql query.

How about my EF LINQ do I need to change to make it work correctly?


The sql code generated by the EF Linq query Actually returns the correct results if they run in the SQL Explorer.

+3
1

, "" , , . EF , , . , , EF, , ( ). Linq-to-sql DataContext.

+4

All Articles