开发者

Preventing Nhibernate from persisting a specific collection in a class

I have a Sponsor object which has a collection that looks like this...

public virtual IDictionary<SettingId, object> SettingValueDefaults { get; set; }

These are actually being pulled as a subset of a larger table. I need to be able to read from these, and that is working correctly.

However, I would like to be able to make run-time changes to this collection, and have nhibernate ignore those changes, or even trying to persist the collection at all.

Again, I need nhibernate to retreive the data, so I can use it in code, but not persist the data changes I make to the collection during execution.

The mapping for this collection is below :

 <map name="SettingValueDefaults" cascade="none">
   <cache usage="read-write" region="Sponsors" />
   <key not-null="true" column="SponsorId"/>
   <index column="SettingId" type="HealthTools.Core.Domain.Model.Sponsor.Settings.SettingId, HealthTools.Core"/>
   <element column="DefaultValue" type="HealthTools.Infrastructure.DataAccess.SqlVariant, HealthTools.Infrastructure"/>
   <loader query-ref="GetDefaultSettingValues" />
  </map>

Here is the error I am receiving from Nhibernate when tries to persist the Sponsor object.

"Invalid object name 'HealthTools.dbo.SettingValueDefaults"

This is occuri开发者_StackOverflow中文版ng because there is no SettingsValueDefaults table, the map is just pulling data from the Sponsor.Settings table via the GetDefaultSettingValues function.


You'll want to make it read-only:

<map name="SettingValueDefaults" cascade="none" access="readonly">
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜