0

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?

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Hi. I mean complex and slow statements.
@Eduardo - you can't really, but there's nothing to stop you from writing a really complex and slow SQL statement either.
@Eduardo: As Eric stated, LINQ will allow complex and slow SQL statements, just like SQL will. One disadvantage to LINQ is that the queries aren't known ahead of time, so some DB optimizations aren't possible. General optimizations are automatic: LINQ will optimize the queries, and then SQL Server will optimize the queries.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.