小编isu*_*anu的帖子

流畅的NHibernate多对多在链接表上创建聚簇索引

我有两个多对多关系的实体.

 public class SecurityGroupMappingOverride : IAutoMappingOverride<SecurityGroup>
{
    public void Override(AutoMapping<SecurityGroup> mapping)
    {
        mapping.HasManyToMany(x => x.Actions).ParentKeyColumn("securityGroupId").ChildKeyColumn("actionId").
            LazyLoad().Table("ActionGroups");

        mapping.HasManyToMany(x => x.Members).ParentKeyColumn("securityGroupId").ChildKeyColumn("userId").
            LazyLoad().Inverse().Table("UserGroups");

        mapping.Map(x => x.Name).Length(64);

    }
}
Run Code Online (Sandbox Code Playgroud)

所以我想在表UserGroups的两列(userId,securityGroupId)上创建聚簇索引.

或者只是在两个列上的UserGroups上创建主键,因为同时不能是两个相同的链接.

谢谢

nhibernate orm fluent-nhibernate

6
推荐指数
1
解决办法
958
查看次数

与Nhibernate Session.Get和Session.CreateCriteria的区别

Nhibernate Session.Get和Session.CreateCriteria有什么区别?

我的故事是:

在我们的产品中,我们通过添加一个接口ISoftDeletable实现了softDeletion,实现此接口的每个类都有deletedDate和deletedBy字段.我们还有AuditableEntity类,这意味着实现它的每个类都有:createdDate,createdBy,modifiedDate,modifiedBy.

以下是消息来源:

public class SaveUpdateEventListener : DefaultSaveEventListener
{

    private readonly ISecurityContextService securityContextService;

    public SaveUpdateEventListener(ISecurityContextService securityContextService)
    {
        this.securityContextService = securityContextService;
    }

    protected override object PerformSaveOrUpdate(SaveOrUpdateEvent @event)
    {
        this.PrepareAuditableEntity(@event);
        return base.PerformSaveOrUpdate(@event);
    }


    private void PrepareAuditableEntity(SaveOrUpdateEvent @event)
    {
        var entity = @event.Entity as AuditableEntity;

        if (entity == null)
        {
            return;
        }

        if (this.securityContextService.EdiPrincipal == null)
        {
            throw new Exception("No logged user.");
        } 

        if (entity.Id == 0)
        {
            this.ProcessEntityForInsert(entity);
        }
        else
        {
            this.ProcessEntityForUpdate(entity);
        }
    }


    private void ProcessEntityForUpdate(AuditableEntity entity)
    {
        entity.ModifiedBy …
Run Code Online (Sandbox Code Playgroud)

nhibernate soft-delete

3
推荐指数
1
解决办法
1859
查看次数

使用nant xmlpoke更改nhibernate配置

如何使用nant从nhibernate.config文件更改连接字符串

问题是所有的例子都是关于改变属性值,但是nhibernate有内部文本

EQ:

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
 <session-factory>
    <property name="connection.connection_string">Data Source.\server;Database=UnitTestDb;UID=user;pwd=pass;</property>
    <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
    <property name="show_sql">true</property>
    <property name="connection.release_mode">auto</property>
    <property name="adonet.batch_size">500</property>
    ....
Run Code Online (Sandbox Code Playgroud)

我需要更改属性connection.connection_string

<xmlpoke        file="${nhibernate.file}"
        xpath="/hibernate-configuration/session-factory/add[@key='connection.connection_string']/@value"
        value="${connection.string}">
</xmlpoke>
Run Code Online (Sandbox Code Playgroud)

这在这种情况下不起作用.

谢谢

nant nhibernate xmlpoke

2
推荐指数
1
解决办法
1690
查看次数

标签 统计

nhibernate ×3

fluent-nhibernate ×1

nant ×1

orm ×1

soft-delete ×1

xmlpoke ×1