I'm having trouble working with Entity Framework and PostgreSQL, does anybody know how to join two tables and use the second table as a where clause?
The select I want to do in Entity Framework would be in SQL:
SELECT ai.id, ai.title, ai.description, ai.coverimageurl
FROM app_information ai
INNER JOIN app_languages al on al.id = ai.languageid
WHERE al.languagecode = 'es'
Currently I have this
var appInformationToReturn = context.app_information
.Join(
context.app_language,
ai => ai.languageid,
al => al.id,
(ai, al) => new AppInformation()
{
id = ai.id,
title = ai.title,
description = ai.description,
coverimageurl = ai.coverimageurl
})
.Where()
.FirstOrDefault();
I don't know how to build the where clause.
.Where(x => x.languagecode="es"). Add propertylanguagecodeinAppInformationclass. you can also use asnew { x,y,z.....}in place ofnew AppInformation()Selectis last, but other operators does not require to be in the same order as SQL. For instance, there could be multipleWhere, and they could be at any point of the query chain. In your case, you could simply insertWhereinside theJoin, e.g..Join(context.app_language.Where(al => al.languagecode = "es"), ...