1

I have two IEnumerables called IEnumerable<TBL_Country> and IEnumberable<TBL_City> which their table definitions came from my ORM and I would like to execute the following Expression Function in order to join the IEnumerables but it's not possible. Any Idea!

IEnumerable<TBL_COUNTRY> country = new IEnumerable<TBL_Country>();
IEnumerable<TBL_COUNTRY> city = new IEnumerable<TBL_CITY>();
Expression<Func<TBL_COUNTRY,TBL_CITY,bool>> func =
    (p,q) => p.fk_city_id = q.pk_city_id & p.name = "SomeName";
Rawling
  • 49,248
  • 7
  • 89
  • 127
  • 1
    they arent both called IEnumerable, IEnumerable is their type. one is called country, the other city. – Inbar Rose Nov 05 '12 at 09:48
  • 1
    At the very least, your lambda result should be `p.fk_city_id == q.pk_city_id && p.name == "SomeName"` - double `=` for logical equality check, double `&` (usually) for logical AND. – Rawling Nov 05 '12 at 10:05
  • 1
    Quite apart from any other errors, you're performing assignment (`=`) rather than equality comparison (`==`) in your expression. The compiler is probably telling you that. – Damien_The_Unbeliever Nov 05 '12 at 10:06
  • 1
    Have you looked at http://stackoverflow.com/questions/4961910/joining-or-appending-two-ienumerable-sequences?rq=1 ? Might be a more elegant way of fixing your problem – seg Nov 05 '12 at 10:14
  • If you want to join two enumerables check this question. http://stackoverflow.com/questions/2723985/linq-join-2-listts You should be able to rework that answer into a func that joins your lists. – BenCr Nov 05 '12 at 10:24
  • 1
    ...and you can't create an instance of IEnumerable (i.e. new IEnumerable()). It's an interface, hence the I prefix. – BenCr Nov 05 '12 at 10:25

0 Answers0