English 中文(简体)
Nhenate 3. 3 当使用公约时, 无法更新我实体的代号 。 可能存在错误吗?
原标题:NHibernate 3.3 loquacious mapping when using conventions the id of my entities is not being updated after save. Possible bug?

简短的版本:

当我拯救一个实体时,使用Nhibertate 3.3中的公约时,该代号财产没有更新。

详细版本 :

实体 I 财产

public virtual Guid GuitarId { get; protected set; }

数据库里保存了这些实体的地图, 但数据库里没有我实体的代号, 即使我试图加载实体时, 也完全忽略了这些实体。

    mapper.BeforeMapClass += (model, type, classCustomizer) =>
    {
        classCustomizer.Id(x =>
        {
            x.Column(type.Name + "Id");
            x.Generator(Generators.GuidComb);
        });
    };

试图获得一个保存的实体,我得到了人口 所有的实体领域 除了ID,我试图访问 ID财产 只是以防它 懒惰但没有运气:

var g = session.Get<Guitar>(existingId);

如果我推翻一个实体的 ID 映射, 我保存后得到正确的 ID 属性

    mapper.Class<Guitar>(map =>
    {
        map.Id(x => x.GuitarId, x =>
        {
            x.Generator(Generators.GuidComb);
        });
    });

问题在于 beforeMapClass 事件, 有什么建议吗?

我错过什么了吗 还是这个虫子

最佳回答

您的基于公约的块块没有定义哪个属性代表主密钥; 只有它所绘制的“ 坚固的> 数据库列

当您手动绘制它时,您正在定义属性,而该列默认使用相同的名称;这就是为什么它起作用。

这项附加公约将注意界定Id财产的定义。

mapper.IsPersistentId((mi, d) => mi.Name == mi.DeclaringType.Name + "Id");
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签