Please, help with advice :)
How can we use MethodInterception aspect with [Field]?
It seems, that our aspect replaces DO.
Aspect:
[Serializable]
public class SetAsParentAttribute : MethodInterceptionAspect
{
public override void OnInvoke(MethodInterceptionArgs args)
{
((BaseEntity)args.Instance).ParentEntity = (BaseEntity)args.Arguments[0];
}
}
Entities:
[Serializable]
[HierarchyRoot(InheritanceSchema = InheritanceSchema.ConcreteTable)]
public abstract class BaseEntity : Entity
{
[Field, Key]
public int Id { get; private set; }
[Field(Nullable = false)]
public int IdSection { get; private set; }
[Field]
public BaseEntity ParentEntity { get; set; }
}
public class NewsPage : BaseEntity
{
[Field]
public string Test { get; set; }
[Field]
public EntitySet<OneNewsPage> ChildEntitySetNews { get; set; }
}
public class OneNewsPage : BaseEntity
{
public OneNewsPage(int idSection)
: base(idSection)
{
}
[Field]
public DateTime DateTime { get; set; }
[Field]
public string ShortText { get; set; }
[Field]
[Association(PairTo = "ChildEntitySetNews", OnOwnerRemove = OnRemoveAction.Clear, OnTargetRemove = OnRemoveAction.Cascade)]
public NewsPage Parent { get; [SetAsParent] set; }
}
Generated code:
[Field]
[Association(OnOwnerRemove = OnRemoveAction.Clear, OnTargetRemove = OnRemoveAction.Cascade, PairTo = "ChildEntitySetNews")]
public NewsPage Parent
{
[DebuggerNonUserCode] get
{
return this.GetFieldValue<newspage>("Parent");
}
[DebuggerNonUserCode] private set
{
MethodInterceptionArgsImpl interceptionArgsImpl = new MethodInterceptionArgsImpl((object) this, (Arguments) new Arguments<newspage>()
{
Arg0 = value
});
interceptionArgsImpl.Method = OneNewsPage.\u003C\u003EzAspects.m5;
interceptionArgsImpl.TypedBinding = (MethodBinding) OneNewsPage.\u003Cset_Parent\u003EcBinding.singleton;
OneNewsPage.\u003C\u003Ez__Aspects.a5.OnInvoke((MethodInterceptionArgs) interceptionArgsImpl);
}
}
So there is no this.GetFieldValue in Set.
What should we do?
asked
Jun 24 '11 at 08:20
Ness
155●23●23●28