Home > Mobile >  LINQ, EF Core : pull record from one list where it exist in other list
LINQ, EF Core : pull record from one list where it exist in other list

Time:10-12

I am working on a .NET 5 with Entity Framework Core application.

I have two lists:

  1. List of strongly typed class data creditCallRecords
  2. List of ids only in format List<string>

I need to pull only those records from creditCallRecords where the id is contained in that second List<string>.

I have tried to use the following LINQ code, but I'm getting errors:

(from csvRecord in creditCallRecords
 where csvRecord.CardEaseReference.Contains(recordReferencesToProcess)
 select csvRecord);

Error

Cannot convert system.collection.Generic.List to Char

CodePudding user response:

You wrote where clause in wrong direction. Try

 where recordReferencesToProcess.Contains(csvRecord.CardEaseReference)

as recordReferencesToProcess is List<string> and it should contains csvRecord.CardEaseReference. In other way string from csvRecord.CardEaseReference is converted into char[] that causing an error

  • Related