InsertOnSubmit versus Add versus Attach
Posted: Wed 19 Aug 2009 10:12
Hello,
Can somebody tell me the difference between then methods:
db.Customers.insertOnSubmit() ;
db.Customers.Add();
db.Customers.Attach() ?
I ask this because the next Microsoft example:
Customer cust =
new Customer {
CustomerID = "ABCDE",
ContactName = "Frond Smooty",
CompanyTitle = "Eggbert's Eduware",
Phone = "888-925-6000"
};
// Add new customer to Customers table
db.Customers.Add(cust);
doens't work for me. I cannot use the last statement:
db.Customers.Add(cust);
because I don't have the Add-method.
I can use Attach or InsertOnSubmit() but now I am confused on what to use.
Thank you
Can somebody tell me the difference between then methods:
db.Customers.insertOnSubmit() ;
db.Customers.Add();
db.Customers.Attach() ?
I ask this because the next Microsoft example:
Customer cust =
new Customer {
CustomerID = "ABCDE",
ContactName = "Frond Smooty",
CompanyTitle = "Eggbert's Eduware",
Phone = "888-925-6000"
};
// Add new customer to Customers table
db.Customers.Add(cust);
doens't work for me. I cannot use the last statement:
db.Customers.Add(cust);
because I don't have the Add-method.
I can use Attach or InsertOnSubmit() but now I am confused on what to use.
Thank you