Reputation: 34208
when we work with ado.net then we can pass multiple sql separated by comma. here is one example.
SqlConnection connection = new SqlConnection();
SqlCommand command = new SqlCommand();
connection.ConnectionString = connectionString; // put your connection string
command.CommandText = @"
update table
set somecol = somevalue;
insert into someTable values(1,'test');";
command.CommandType = CommandType.Text;
command.Connection = connection;
try
{
connection.Open();
}
finally
{
command.Dispose();
connection.Dispose();
}
i like to know how could i construct EF linq based query which will fetch data from multiple table but there is no relation between two table. so we can not perform join.
so show me a example where EF will fetch data from student and product table without any join with one db round trip. is it possible which was possible by ado.net as per my above example.
var query = from data in context.Student
orderby data.name
select data;
var query = from data in context.Product
orderby data.name
select data;
when two above query will run then two database round trip will occur or one ?
i need to fetch data from two table called student and product with one db round trip just like my above EF linq query.
if possible then discuss with sample code. thanks
Upvotes: 2
Views: 1062
Reputation: 1059
This is not supported out of the box, but there exists a "future queries" package that enables this: https://www.nuget.org/packages/Z.EntityFramework.Plus.QueryFuture.EF6/
Upvotes: 2