先解释下,不是怕翻书,是不知道翻哪里,整本看完估计活不用干了。先谢谢了
1.
public abstract class Specification<T> : ISpecification<T>
{
// 下面这行是抽象函数?返回一个Expression<Func<T, bool>>对象?Func在这里做什么用?光写个get也能编译通过?
public abstract Expression<Func<T, bool>> Expression { get; } public bool IsSatisfiedBy(T obj)
{
return this.Expression.Compile()(obj);
}
}
public class OrderCustomerMatchesSpecification : Specification<SalesOrder>
{
private Customer customer;
public OrderCustomerMatchesSpecification(Customer customer)
{
this.customer = customer;
}
public override Expression<Func<SalesOrder, bool>> Expression
{
// => 是新符号么?
get { return p => p.Customer.Id.Equals(customer.Id); }
}
}
1.
public abstract class Specification<T> : ISpecification<T>
{
// 下面这行是抽象函数?返回一个Expression<Func<T, bool>>对象?Func在这里做什么用?光写个get也能编译通过?
public abstract Expression<Func<T, bool>> Expression { get; } public bool IsSatisfiedBy(T obj)
{
return this.Expression.Compile()(obj);
}
}
public class OrderCustomerMatchesSpecification : Specification<SalesOrder>
{
private Customer customer;
public OrderCustomerMatchesSpecification(Customer customer)
{
this.customer = customer;
}
public override Expression<Func<SalesOrder, bool>> Expression
{
// => 是新符号么?
get { return p => p.Customer.Id.Equals(customer.Id); }
}
}
http://www.cnblogs.com/FlyEdward/tag/Linq%E8%A1%A8%E8%BE%BE%E5%BC%8F%E6%A0%91%20linq%20%E8%A1%A8%E8%BE%BE%E5%BC%8F%E6%A0%91/