I have a class representing a table on database that is defined:
public class MyClass{
public int MyClassId{get;set;}
public string Name{get;set;}
public string LastNamw{get;set;}
public DateTime From{get;set;}
public DateTime To{get;set;}
}
On which I want to run some search query against oracle database.
Now the question is :
var list = context.MyClass
.Where(x => x.From>= FromMyDate)
.Where(x => x.To <= ToMyDate);
var list = context.MyClass
.Where(x => x.From>= FromMyDate && x.To <= ToMyDate);
Is it better to use multiple rows with where condition or one? And why... please
As far as I understand, I use multiple where clauses when I want to search on result of the first condition.
It shouldn't matter
You are just creating an Expression tree that is passed to the Oracle Provider and it is the provider's job to create the resultant SQL query. Even though the Expression tree would be slightly different between the two, it should still result in the same sql. I like to use a sql profiler to make sure my linq queries are producing efficient sql.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With