データベースからレコードを取得しない基本的な方法があります。構成では、問題なくテーブルを作成します。常にゼロ レコードを返します。以下に設定ファイルを追加しました。何が問題なのかわかりません。
public List<Note> GetAll()
{
var session = NHibernateHelper.OpenSession();
var note = session.CreateCriteria<Note>().List<Note>();
return note.ToList();
}
ヘルパー:
public class NHibernateHelper
{
private static ISessionFactory _sessionFactory;
private static ISessionFactory SessionFactory
{
get
{
if (_sessionFactory == null)
{
InitializeSessionFactory();
}
return _sessionFactory;
}
}
private static void InitializeSessionFactory()
{
_sessionFactory = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008
.ConnectionString(
@"Server={server};Database=ToDo;
User ID=lorem;Password=lorem;
Trusted_Connection=False;Encrypt=True;Connection Timeout=30;")
.ShowSql()
)
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Note>())
.ExposeConfiguration(cfg => new SchemaExport(cfg)
.Create(true, true))
.BuildSessionFactory();
}
public static ISession OpenSession()
{
return SessionFactory.OpenSession();
}
}