Here is something super generic that you could use:
public virtual EntityCollection<T> GetItemsByExpression(Expression<Func<T, bool>> expression)
{
if (this.EntityTypeNumber < 0) return new EntityCollection<T>();
using (IDataAccessAdapter adapter = _adapter.Create())
{
LinqMetaData metaData = new LinqMetaData(adapter);
var q = (metaData.GetQueryableForEntity(this.EntityTypeNumber) as DataSource2<T>)
.Where<T>(expression);
return (q as ILLBLGenProQuery)
.Execute<EntityCollection<T>>();
}
}
The only thing you need to somehow maintain is the EntityTypeNumber for Entity T. Also, the line
_adapter.Create()
simply returns a new DataAccessAdapter.
The way to use it is:
o.GetItemsByExpression(entity => entity.Id == 2)
Enjoy!