Reputation: 245
How do I view the SQL generated by linq on insert statement ?
using (DataClasses1DataContext db = new DataClasses1DataContext())
{
db.tblCameras.InsertOnSubmit(new tblCamera() {
CameraID=textbox1.Text,
IPAddress=textbox2.Text,
});
db.SubmitChanges();
}
i'm planning to execute generated sql on another copy of this db , i have tried to use
db.Log = Console.Out;
but this generated is not useful in my case
INSERT INTO [dbo].[tblCamera]([CameraID], [IPAddress])
VALUES (@p0, @p1)
-- @p0: Input Int (Size = -1; Prec = 0; Scale = 0) [14]
-- @p1: Input NVarChar (Size = 4000; Prec = 0; Scale = 0) [1]
-- Context: SqlProvider(Sql2008) Model: AttributedMetaModel Build: 4.6.1586.0
any suggestion!
Upvotes: 0
Views: 1673
Reputation: 1570
You should try to catch the query with SQL Profiler, and you can easily copy/paste the SQL query from there.
Check this: https://msdn.microsoft.com/hu-hu/library/ms175047.aspx
Upvotes: 1