本文介绍了没有persister:流利的nHibernate异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了MVCTemplate.Common.Entities.User没有persister异常。我谷歌这个问题,并应用我发现的所有解决方案。但对我来说都是无用的。
有没有人知道我做错了什么?



我的用户类代码是

  public class User 
{
public virtual Guid UserID {get;私人设置}
public virtual string UserName {get;组; }
public virtual string Password {get;组; }
公共虚拟字符串FullName {get;组; }
public virtual string Email {get;组; }
public virtual TimeSpan LastLogin {get;组; }
public virtual bool IsActive {get;组; }
public virtual DateTime CreationDate {get;组; }
公共虚拟IList< UserInRole> UserInRoles {get;组;



$ b

用户映射:

  public class UserMap:ClassMap< User> 
{
public UserMap()
{
Table(tblUsers);
Id(user => user.UserID).GeneratedBy.GuidComb();
Map(user => user.UserName).Not.Nullable();
Map(user => user.Password).Not.Nullable();
Map(user => user.FullName).Not.Nullable();
Map(user => user.Email).Not.Nullable();
Map(user => user.LastLogin).Not.Nullable();
Map(user => user.IsActive).Nullable();
Map(user => user.CreationDate).Not.Nullable();
HasMany(user => user.UserInRoles);




$ b $ F $ H

  return Fluently.Configure()
.Database(FluentNHibernate.Cfg.Db.MsSqlConfiguration.MsSql2008
.ConnectionString(c => c ();
b.Mappings(m =>
m.FluentMappings.AddFromAssemblyOf< User>())
.BuildSessionFactory();

谢谢

解决方案请检查您的映射类是否公开。

检查您的流利配置中是否有这样的内容....



$ p $ .Mappings(m => m.FluentMappings.AddFromAssemblyOf< UserMap>())


i m getting the exception "No persister for: MVCTemplate.Common.Entities.User" . I Google this issue and apply all the solution i found. but all are useless for me. Does anyone know what i m doing wrong ?

my User Class code is

public class User
{
    public virtual Guid UserID { get; private set; }
    public virtual string UserName { get; set; }
    public virtual string Password { get; set; }
    public virtual string FullName { get; set; }
    public virtual string Email { get; set; }
    public virtual TimeSpan LastLogin { get; set; }
    public virtual bool IsActive { get; set; }
    public virtual DateTime CreationDate { get; set; }
    public virtual IList<UserInRole> UserInRoles { get; set; }
}

User Mapping :

public class UserMap : ClassMap<User>
{
    public UserMap()
    {
        Table("tblUsers");
        Id(user => user.UserID).GeneratedBy.GuidComb();
        Map(user => user.UserName).Not.Nullable();
        Map(user => user.Password).Not.Nullable();
        Map(user => user.FullName).Not.Nullable();
        Map(user => user.Email).Not.Nullable();
        Map(user => user.LastLogin).Not.Nullable();
        Map(user => user.IsActive).Nullable();
        Map(user => user.CreationDate).Not.Nullable();
        HasMany(user => user.UserInRoles);
    }
}

FNH Configuration :

return Fluently.Configure()
            .Database(FluentNHibernate.Cfg.Db.MsSqlConfiguration.MsSql2008
            .ConnectionString(c => c.FromConnectionStringWithKey("FNHConnection"))
            )
            .Mappings(m =>
                m.FluentMappings.AddFromAssemblyOf<User>())
            .BuildSessionFactory();

Thanks

解决方案

Double check that your mapping class is public.

Check that you have something like this in your fluent config....

.Mappings(m => m.FluentMappings.AddFromAssemblyOf<UserMap>())

这篇关于没有persister:流利的nHibernate异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 11:21