Hi, I am using Fluent NHibernate using C#. I am trying to delete an object. But it gives me an error as "deleted object would be re-saved by cascade (remove deleted object from associations)" My mapping is like this
public VMapping() { Id(x => x.Id, "VID"); HasMany(x => x.SeatMaps).KeyColumnNames.Add("VID").Inverse().Cascade.AllDeleteOrphan().Not.LazyLoad(); Component(x => x.Name, c => c.Map(y => y.Value, "VName")); Map(x => x.Code, "ExtRefCode"); References(x => x.Region, "RegionId").Not.LazyLoad(); }
public VSMMapping() { Id(x => x.Id, "VSMId"); References(x => x.Venue, "VId").Not.LazyLoad(); HasMany(x => x.VSMSItems). KeyColumnNames.Add("VSMId"). Inverse(). AsSet(). Cascade.AllDeleteOrphan(); Component(x => x.Name, c => c.Map(y => y.Value, "VSMName")); Map(x => x.Description, "Description"); }
and my delete code is
session.Delete(venueSeatMap);
But when i change the mapping of VSMMapping() as
public VSMMapping() { Id(x => x.Id, "VSMId"); References(x => x.Venue, "VId"); HasMany(x => x.VSMSItems). KeyColumnNames.Add("VSMId"). Inverse(). AsSet(). Cascade.AllDeleteOrphan(); Component(x => x.Name, c => c.Map(y => y.Value, "VSMName")); Map(x => x.Description, "Description"); }
It works perfectly. But I dont want to use LazyLoading. Can anyone tell me Y is the Delete not working when not using lazyloading. Is there any workaround for delete when not using lazyloading?
Any help is much appreciated. Thanks
SVP
|