DBLinq、SQLiteを使用して接続が機能している小さなコードサンプルを投稿できる人はいますか?私はこれをVS2010WPF環境で2日間起動して実行するのに苦労しています。接続文字列はうまくいったと思いますが、サンプルが稼働しているのを見てみたいと思います。
var con = new SQLiteConnection("DbLinqProvider=Sqlite;Version=3;Data Source=c:\\temp\\testdb.db3;");
DataSource db = new DataSource(con);
var q = from c in db.Person
select c;
foreach (Person tempPerson1 in q)
MessageBox.Show(tempPerson1.Name);
私のDBMLファイル(関連コード)-「Main」を「DataSource」に変更し、SQLiteをSystem.Data.SQLite.SQLiteConnectionに変更してコンパイルしました。
[global::System.Data.Linq.Mapping.DatabaseAttribute(Name="DataSource")]
[global::System.Data.Linq.Mapping.ProviderAttribute(typeof(System.Data.SQLite.SQLiteConnection))]
public DbLinq.Data.Linq.Table<Person> Person {
get {
return this.GetTable<Person>();
}
}
[global::System.Data.Linq.Mapping.TableAttribute(Name="Datasource.Person")]
public partial class Person {
private string _id;
private string _name;
public Person() { }
[global::System.Data.Linq.Mapping.ColumnAttribute(
Name="id", Storage="_id", DbType="VARCHAR(10)")]
public string ID {
get {
return this._id;
}
set {
if ((this._id != value)) {
this._id = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(
Name="name", Storage="_name", DbType="VARCHAR(25)")]
public string Name {
get {
return this._name;
}
set {
if ((this._name != value)) {
this._name = value;
}
}
}
}
現在、そのようなテーブルがないというSQLiteエラーが発生しています:Datasource.Personと私はパスと接続文字列が正しいと信じています。DBMetalからDBMLファイルとCSファイルの両方を作成する必要がありますか?