tags:

views:

30

answers:

1

Hello. Right now i'm exploring LINQ-to-SQL using Visual Studio 2010 beta. I'm trying to understood the bascis for now, without magics light code auto generated from schemes and from sqlmetal. I have tried the following code:

  public class Database : DataContext
  {
    public Database( string s ) : base( s ) {}
    public Table< DUser > items;
  }

  [Table( Name = "users" )]
  public class Item
  {
    [Column]
    public string s;
  }
  // Using SQL Compact.
  var db = new Database( "Data Source=test.sdf;" );
  // Works fine and creates database.
  db.CreateDatabase();

But how to ADD data to database created / opened? Tutorials i have read shows something like db.Items.Add(), but Table<> don't have Add() member :(. Any insigths without using scheme / sqlmetal?

+2  A: 

You're looking for the Table<T>.InsertOnSubmit method (followed of course by DataContext.SubmitChanges). Similarly DeleteOnSubmit for deletions.

itowlson