开发者

Avoiding Linq real database operations

开发者 https://www.devze.com 2023-02-08 04:47 出处:网络
If I implement this interface: public int开发者_JAVA百科erface IProductsRepository { IQueryable<Product> Products { get; }

If I implement this interface:

public int开发者_JAVA百科erface IProductsRepository
{
    IQueryable<Product> Products { get; }
}

... using Linq to SQL

Will this produce real database queries?

var x = from p in repositoryInstance.Products where price > 100;

If so how can I avoid callers from executing complex and slow sql statements?


LINQ to SQL (and other LINQ providers) will not allow invalid SQL statements. If possible, a compile-time error will prevent the code from compiling. If that's not possible, an error will be thrown at runtime.

0

精彩评论

暂无评论...
验证码 换一张
取 消