I have a question about LinqToSql approach.
Model:
public class Person
{
public int ID { get; set; }
public string LastName { get; set; }
public Phone Phone { get; set; }
}
public class Phone
{
public int ID { get; set; }
public string Number { get; set; }
public bool IsUkr()
{
return this.Number.StartsWith("380");
}
}
I use Nhibernate as ORM and I want to execute
IQueryable<Phone> phones = session.Query<Phone>().Where(x => x.IsUkr());
But Nhibernate can't translate this expression into sql because it doesn't know about method IsUkr().
Solution is to write some wrapper to IQueryable interface and use:
session.Query<Phone>().ToExpandable().Where ....
But I don't understand how translate LambdaExpression x => x.IsUkr() into
x => x.Number.StartsWith("380")
Can someone help me?