I was reading that linq was lazy and that it did not executed the query until it needed to.
if that is the case why does this code fails:
var db = new Data.DataClasses1DataContext(@"Data Source=.\sqlexpress;Initial Catalog=MyDb;Integrated Security=True");
var companies = db.Customers.Where(x => x.Company=="Foo");
var query = companies.ToString();
if I run that code in a computer that does not have sql server installed it will not run why? I am not doing any statement that needs data. If I would call companies.ToList()
then its ok for the code to fail. Is there a way I can make use of Linq to SQL Classes
without using a connection. I know the moment I do ToList() or try to enumerate through the results I will get an error. I just want to use Linq to Sql Classes in order to generate the SQL statements and see them as a string.
I have a client and a server. The server is a WCF service and the client is a console application. I will send the query encrypted for cases where the user is not entering it. I will like to generate my queries using Linq to Sql classes
it does not make sence I have to install sql server on the client just so that I can generate the queries.
My temporary solution is to create a second database on the same server. That database will be allowed to accept remote connections and the whole purpose of it is so that the line
var db = new Data.DataClasses1DataContext(@"some remote connection string");
works. Once I initialize that line I will never need the connection again. It makes no sense.