So I think I have been able to find a solution to this. Using ExpressionVisitor and help from this post
I modified the VisitMember method:
protected override Expression VisitMember(MemberExpression node)
{
string sDbField = ((SFWBusinessAttributes)node.Expression.Type.GetProperty(node.Member.Name).GetCustomAttribu`tes(typeof(SFWBusinessAttributes), true)[0]).DBColumn;
var expr = Visit(node.Expression);
if (expr.Type != node.Type)
{
MemberInfo newMember = expr.Type.GetMember(sDbField).Single();
return Expression.MakeMemberAccess(expr, newMember);
}
return base.VisitMember(node);
}
To pull the Attribute off of the Property of the Business Object.
To call everything I can do from the app:
BusObj.Query(a => a.IsDeleted != true && a.Company.Contains("Demo"))
Which calls a method in the business object
public List<Account> Query(Expression<Func<Account, bool>> expression)
{
using (Data.CustomerData data = new Data.CustomerData(_connstring))
{
return MapList(data.Query<Data.Database.ACCOUNT>(expression.Convert<Account, Data.Database.ACCOUNT>()).ToList());
}
Performance seems pretty good, I know there is going to be a hit with the mapping but it is something I can live with for now.