I made a little WPF application with a SQL CE database.
I built the following code with LINQ to get data out of the database, which was surprisingly easy. So I thought ‘this must be LINQ-to-SQL’.
Then I did ‘add item’ and added a ‘LINQ-to-SQL classes’ .dbml file, dragged my table onto the Object Relational Designer but it said, ‘The selected object uses an unsupported data provider.’
So then I questioned whether or not the following code actually is LINQ-to-SQL, since it indeed allows me to access data from my SQL CE database file, yet officially ‘LINQ-to-SQL’ seems to be unsupported for SQL CE.
So is the following ‘LINQ-to-SQL’ or not?
using System.Linq; using System.Data.Linq; using System.Data.Linq.Mapping; using System.Windows; namespace TestLinq22 { public partial class Window1 : Window { public Window1() { InitializeComponent(); MainDB db = new MainDB(@'Data Source=App_Data\Main.sdf'); var customers = from c in db.Customers select new {c.FirstName, c.LastName}; TheListBox.ItemsSource = customers; } } [Database(Name = 'MainDB')] public class MainDB : DataContext { public MainDB(string connection) : base(connection) { } public Table<Customers> Customers; } [Table(Name = 'Customers')] public class Customers { [Column(DbType = 'varchar(100)')] public string FirstName; [Column(DbType = 'varchar(100)')] public string LastName; } }
This msdn article notes that while sdf is supported by the LINQ to SQL runtime, it is not supported by the designer.
To Quote: