I try to write this SQL query in LinqToSql:
Code: Select all
SELECT *
FROM directive_line t1
WHERE (t1."Id", t1."IdSomeOther") in ((13, 10), (11, 9))
Code: Select all
public class ObjectForQuery
{
public long Id{get;set;}
public long IdSomeOther{get;set;}
}
....
var objectsForSearch = new List
{
new ObjectForQuery{Id = 13, IdSomeOther = 10},
new ObjectForQuery{Id = 11, IdSomeOther = 9},
};
var list = (from directiveLineDB in context.DirectiveLines
where objectsForSearch.Select(o => new {o.Id, o.IdSomeOther }).Contains(new { Id = directiveLineDB .Id, IdSomeOther= directiveLineDB.IdSomeOther})
select directiveLineDB).ToList();
"Could not format node 'New' for execution as SQL."
I'm do something wrong? How can I write this sql query in Linq?
dotConnect for PostgreSQL: 4.65.79.0