私は NHibernate を勉強し、ビデオ コースからアプリケーションの作成を繰り返してみ
ました。データベース、モデル、XML ファイルを作成し、このコードを書きました。
using System;
using System.Reflection;
using NHibernate.Cfg;
using NHibernate.Dialect;
using NHibernate.Driver;
namespace NHibernateDemo
{
internal class Program
{
static void Main(string[] args)
{
var cfg = new Configuration();
cfg.DataBaseIntegration(x =>
{
x.ConnectionString = "Server=localhost; Database=NHibernateDemo; Integrated Security = SSPI";
x.Driver<SqlClientDriver>();
x.Dialect<MsSql2008Dialect>();
});
cfg.AddAssembly(Assembly.GetExecutingAssembly());
var sessionFactory = cfg.BuildSessionFactory();
using (var session = sessionFactory.OpenSession())
using (var tx = session.BeginTransaction())
{
var customers = session.CreateCriteria<Customer>()
.List<Customer>();
foreach (var customer in customers)
{
Console.WriteLine("{0} {1}", customer.FirstName, customer.LastName);
}
tx.Commit();
Console.WriteLine("Enter any key to exit...");
Console.ReadKey();
}
}
}
}
しかし、デバッグしようとすると、SqlExeption was unhandled が発生しました
コードにログインとパスワードを追加する必要があると思いますが、その方法を説明してもらえますか?