I have created a LINQ to SQL datacontext with a single datatable in it. I am trying to simply insert a new record into that table. The problem I am coming across is LINQ is not offering an Add method to pass in the new record to. I have seen countless examples where there is an Add method, but I can't seem to get it. Am I completely missing something or is it something else?
using (praetoriaTestDataContext db = new praetoriaTestDataContext()) { PageHit hit = new PageHit(); hit.DateViewed = DateTime.Now; hit.Page = "test"; db.PageHits.Add(hit); //Add method is not available! db.SubmitChanges(); }
Thanks!
Most of the LINQ projection and restriction methods are supported in LINQ to Entities queries, with the exception of those that accept a positional argument. For more information, see Standard Query Operators in LINQ to Entities Queries.
LINQ does not support full outer joins directly, the same as right outer joins.
All LINQ methods are extension methods, defined in the System.
Table's Add and Remove methods have been renamed to InsertOnSubmit and DeleteOnSubmit.
db.PageHits.InsertOnSubmit(hit);
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