predicate builder with two tables

白昼怎懂夜的黑 提交于 2019-12-04 13:03:51

The point is that you have multiple Contacts to a single Party, hence you should decide if you want to have a Party if "any of the Contacts match the street name" or "all of the Contacts match the street name".

For the first case it would be:

predicate = predicate.Or(p => p.Contacts.Any(c => c.streetname.Contains(keyword))));
Richard Forrest

This will work if your model has Contact as an associated object on the party object (and if it doesn't have a one-to-many relation)

predicate = predicate.Or(p => p.Contact.streetname.Contains(keyword));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!