【问题标题】:remove the default Cache setting in Fluent NHibernate删除 Fluent NHibernate 中的默认缓存设置
【发布时间】:2013-12-25 14:17:56
【问题描述】:

我很高兴使用 Fluent NHibernate 为几乎所有实体设置公共缓存,如下所示:

    public static FluentConfiguration Create(string connStr)
    {
        return Fluently.Configure()
          .Cache(x => x.UseSecondLevelCache().ProviderClass<SysCacheProvider>())
          .Mappings(m =>
              {
                  m.FluentMappings
                      .AddFromAssemblyOf<UserMap>()
                      .Conventions.Add(
                        // here the cache is set ReadWrite
                        Cache.Is(x => x.ReadWrite()),
                      );

              })
    }

但仍有一些实体我不想缓存它们。我该怎么办?

public class ActivityMap : EntityMap<Activity>
{
    public ActivityMap()
    {
        References<User>(m => m.Executor);

        //Note: I'm not want to change the cache but REMOVE the cache!
        //Cache.ReadOnly();
    }
}

【问题讨论】:

    标签: nhibernate caching overriding fluent


    【解决方案1】:

    我不确定这是一个真正的解决方案,或者只是在 web.config 的缓存区域节点中设置 expire=0,但不管它是否有效。

    【讨论】:

      猜你喜欢
      • 2010-12-02
      • 1970-01-01
      • 2011-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-31
      相关资源
      最近更新 更多