Eduardo
Eduardo

Reputation: 5943

Avoiding Linq real database operations

If I implement this interface:

public interface 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?

Upvotes: 0

Views: 54

Answers (1)

Stephen Cleary
Stephen Cleary

Reputation: 456777

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.

Upvotes: 3

Related Questions