I think this is just a syntax issue (me not fully understanding linq) I have 2 tables in my entity model , despite having the same key id ([report_relation_id]) I do not have them joined in the model. All I want to do is select all the records in one table where the id fields are equal - and pass in a parameter to the joining table to limit the records.
I have seen a few examples with 3 tables, I tried to follow the same syntax but cant seem to get it to compile.
SQL
select rp_report_product_data.*
from rp_report_product_data , rp_report_relations
where
rp_report_relations.report_group_id = @PARAM_report_group
and
rp_report_relations.report_relation_id = rp_report_product_data.report_relation_id
this doesnt compile:
public IQueryable<rp_report_product_data> Get_RPD(Guid PARAM_report_group)
{
return this.ObjectContext.rp_report_product_data.Where(c => c.rp_report_relations.Any(p => p.report_group_id == PARAM_report_group));
}
(red underline) "Delegate 'System.Func'does not take 1 arguments"
I would rather do this just as a linq statement - I think there is an optional way to do it with an Include - which I know absolutely nothing about, so rather than try learn more stuff I want to stick linq which I basically understand.
edit. Actually Entity framework is already bring back all the rp_report_relations for this PARAM_report_group, so a better way might be to filter it using the records that have already been returned to the below:
public IQueryable<rp_report_relations> GetRp_report_relations(Guid PARAM_report_group)
{
return this.ObjectContext.rp_report_relations.Where(rr => rr.report_group_id == PARAM_report_group);
}