|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Linq To Sql-Beginners Q: can't Add new record (Add() method missinDownloaded VS2008 trial from MS 24 hours ago in order to investigate Linq To Sql. But I'm hitting a strange roadblock, where I am unable to find an Add() method on the dataContext's tables... And without, I can't add a new record. What I have done: a) As I said, its a trial version of VS2008 (although I thought it was all open for 90 days) b) Deleted VS2005 as I was running out of space. c) Which damaged VS2008, so I did a full Repair...(you'll see in a second why I mention all this) d) New Console project e) Created new Database1.MDF, and Cancel last step in order to not create any datasources as I don't need them. f) Create two tables (Task, TaskType) in Db. e) Create constraint in between two. g) Save changes to db. h) Drag both tables onto LinqToSql designer surface i) Save it. Right... at this point I have a DataContext, and have Entities. Should be able to do the following: string connectionString = Properties.Settings.Default.Database1ConnectionString; MyDb context = new MyDb(connectionString); Task t = new Task(); t.Subject = "A new task"; context.Tasks.Add(t); Every single example I've seen shows the Add() method... except, my Tasks doesn't offer it. It offers Aggregate<>, All<> , Any<>....but no Add() method. Other unexpected behavior... Right click on a table in the designer, and the Insert, Update, Delete methods are grayed out and offer no '...' to edit them. ...which is again unlike the description in the MSDN docs and Scott Guthries example articles. so. a) Is it an VS install issue and i have to start all over again? b) Is it a settings issue that I've unset accidentally? c) Is it a gormless thing that's right in front of me, but I can't see? (Most probable reason?) Anyway -- any suggestions on how to move forward again? PS: Is there a dedicated LinqToSql newsgroup? This is because it was changed. This is now InsertOnSubmit to make crystal
clear this is done when you submit changes to the DB rather than immediately. For the second issue are you sure you have a primary key in your tables ? Youll find a web based forum at (hopefully they'll create a linq specific group) : http://forums.microsoft.com/msdn/showforum.aspx?forumid=123&siteid=1 -- Patrice "Sky" <public.skysigal{*AT*}xact-solutions.com> a écrit dans le message de news: F81ADDC5-CB6A-4C1C-929E-7C168DC3C***@microsoft.com...Show quote > Hello: > > Downloaded VS2008 trial from MS 24 hours ago in order to investigate Linq > To > Sql. > But I'm hitting a strange roadblock, where I am unable to find an Add() > method on the dataContext's tables... And without, I can't add a new > record. > > What I have done: > > a) As I said, its a trial version of VS2008 (although I thought it was all > open for 90 days) > b) Deleted VS2005 as I was running out of space. > c) Which damaged VS2008, so I did a full Repair...(you'll see in a second > why I mention all this) > > > d) New Console project > e) Created new Database1.MDF, and Cancel last step in order to not create > any datasources as I don't need them. > f) Create two tables (Task, TaskType) in Db. > e) Create constraint in between two. > g) Save changes to db. > h) Drag both tables onto LinqToSql designer surface > i) Save it. > > Right... at this point I have a DataContext, and have Entities. > Should be able to do the following: > > string connectionString = > Properties.Settings.Default.Database1ConnectionString; > MyDb context = new MyDb(connectionString); > > Task t = new Task(); > t.Subject = "A new task"; > > context.Tasks.Add(t); > > Every single example I've seen shows the Add() method... > except, my Tasks doesn't offer it. It offers Aggregate<>, All<> , > Any<>....but no Add() method. > > Other unexpected behavior... > > Right click on a table in the designer, and the Insert, Update, Delete > methods are grayed out and offer no '...' to edit them. ...which is again > unlike the description in the MSDN docs and Scott Guthries example > articles. > > so. > a) Is it an VS install issue and i have to start all over again? > b) Is it a settings issue that I've unset accidentally? > c) Is it a gormless thing that's right in front of me, but I can't see? > (Most probable reason?) > > Anyway -- any suggestions on how to move forward again? > > PS: Is there a dedicated LinqToSql newsgroup?
Other interesting topics
|
|||||||||||||||||||||||