0

I have run sqlmetal.exe agaisnt my database.

SqlMetal.exe /server:server /database:dbname /code:mapping.cs

I have included this into my solution. So I can now create an object for each of the database tables. Great. I now wish to use ling to query by database. Can I presume that none of the connection etc is handled by the output of sqlmetal.exe. If this is correct what ways can I use ling to query my database?

John
  • 487
  • 8
  • 16

1 Answers1

2

Does the generated code include a Data Context (a class which inherits from System.Data.Linq.DataContext)? If so, then that's probably what you're looking for. Something like this:

var db = new SomeDataContext();
// You can also specify a connection string manually in the above constructor if you want
var records = db.SomeTable.Where(st => st.id == someValue);
// and so on...
David
  • 208,112
  • 36
  • 198
  • 279