有人能推荐一个sqlite c orm代码生成工具吗?
我找到了哈瓦那框架,有什么意见吗?
谢谢
更新
在这种情况下,我使用亚音速。为了帮助其他人,这里有一个创建类并一起使用亚音速和sqlite的“基本”示例。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SQLite;
using SubSonic;
using SubSonic.Schema;
using SubSonic.Repository;
using SubSonic.DataProviders;
namespace SubsonicSqliteTest
{
public class User
{
public User()
{
ID = Guid.NewGuid();
// Set Defaults
FirstName = String.Empty;
LastName = String.Empty;
Username = String.Empty;
Password = String.Empty;
IsAdministrator = 0;
}
public Guid ID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public int IsAdministrator { get; set; }
public DateTime? CreatedDate { get; set; }
public DateTime? LastUpdatedDate { get; set; }
public static User Get(Guid id)
{
string databasePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.ExecutablePath), "Database.db");
IDataProvider provider = ProviderFactory.GetProvider("Data Source=" + databasePath + ";Version=3;New=True;Pooling=True;Max Pool Size=1;", "System.Data.SQLite");
var repository = new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations);
var users = from user in repository.All<User>()
where user.ID == id
select user;
foreach (var user in users)
{
return user;
}
return null;
}
public User Save()
{
string databasePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.ExecutablePath), "Database.db");
IDataProvider provider = ProviderFactory.GetProvider("Data Source=" + databasePath + ";Version=3;New=True;Pooling=True;Max Pool Size=1;", "System.Data.SQLite");
var repository = new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations);
repository.Add(this);
return this;
}
}
}
最佳答案
其他人已经发布了关于NHibernate(特别是与Fluent NHibernate和ADO.NET实体框架,这两者都是伟大的。您也可以查看SubSonic。如果您考虑使用sqlite,那么您的数据库需求必须相当简单,并且非常容易使用SubSonic's SimpleRepository option。