SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 355 | Next

Scott Klein

"Professional LINQ"

In fact, if you run this example and don??™t specify the IsDBGenerated
property, it still won??™t work, although you will get a different error, stating that it cannot insert an explicit
value for the identity column of the table when IDENTITY_INSERT is set to off. LINQ to SQL needs to
know that the table has a primary key, which column the primary key is, and that it is auto-generated.
At that point, LINQ to SQL won??™t see the table as read-only.
Last, when the properties have been filled, the new object needs to be added to the Contact table in the
DataContext and the SubmitChanges method called to usher the changes back to the database.
Update
For an update, the code is going to query for a specific record and update a field of that record. Add
the following code behind the Update button. It queries for the record you inserted in the preceding
example and updates the email address. Keep in mind that when you run this code, the ContactID may
be different for you; be sure to use the correct ContactID.
AdventureWorks db = new AdventureWorks("Integrated Security=sspi");
var con = db.


Pages:
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6