私はNhibernate.Linq 1.0とgithubのマスターからダウンロードしたFluentNhibernateの最新バージョンでNhibernate 2.1.2.4000 GAを使用しています。
いくつかのテストを行っていますが、linq クエリによって取得されたエンティティを削除しようとすると、次のエラーが発生します。
永続化機能なし: NHibernate.Linq.Query`1[[Employees.Core.Entities.Employee, Employees.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]
他のすべての操作 (挿入、更新、および選択) は正常に見えます。
私のエンティティクラス:
public class Employee
{
public Employee()
{
}
public virtual Int32 Id { get; private set; }
public virtual String Name { get; set; }
public virtual String SayHello()
{
return String.Format("'Hello World!', said {0}.", Name);
}
}
マッピング クラス:
public class EmployeeMap : ClassMap<Employee>
{
public EmployeeMap()
{
Id(x => x.Id);
Map(x => x.Name)
.Not.Nullable()
.Length(50);
}
}
構成:
Assembly mappingsAssemly = Assembly.GetExecutingAssembly();
return Fluently.Configure()
.Database( MsSqlConfiguration.MsSql2008
.ConnectionString(connectionString)
.ProxyFactoryFactory(typeof(ProxyFactoryFactory))
.ShowSql())
.Mappings( m => m.FluentMappings.AddFromAssembly(mappingsAssemly))
.BuildSessionFactory();
そして、動作しないコード:
public void RemoveAll()
{
var q = from employee in _session.Linq<Employee>()
select employee;
foreach (var employee in q.ToList())
{
_session.Delete(q);
}
}
何かご意見は?