LINQ-to-SQL and SQL Compact - database file sharing problem

Posted by Eye of Hell on Stack Overflow See other posts from Stack Overflow or by Eye of Hell
Published on 2009-11-19T10:09:40Z Indexed on 2010/05/16 0:50 UTC
Read the original article Hit count: 310

Filed under:
|

Hello.

I'm learing LINQ-to-SQL right now and i have wrote a simple application that define SQL data:

  [Table( Name = "items" )]
  public class Item
  {
    [ Column( IsPrimaryKey = true, IsDbGenerated = true ) ]
    public int Id;
    [ Column ]
    public string Name;
  }

I have launched 2 copy of application connected to the same .sdf file and tested if all database modifications in one application affects another application. But strange thing arise. If i use InsertOnSubmit() and DeleteOnSubmit() in one application, added/removed items are instantly visible in other application via 'select' LINQ queue. But if i try to modify 'Name' field in one application, it is NOT visible in other applicaton until it reconnects the database :(. The test code i use:

  var Items = from c in db.Items
              where Id == c.Id
              select c;
  foreach( var Item in Items )
  {
    Item.Name = "new name";
    break;
  }
  db.SubmitChanges();

Can anyone suggest what i'm doing wrong and why InsertOnSubmit()/DeleteOnSubmit works and SubmitChanges() don't?

© Stack Overflow or respective owner

Related posts about linq-to-sql

Related posts about sql-server-ce