Hi,
I am trying to clone [String(Ignore)] attribute of Nest for my own method that saves process logs. I have already done something but it doesn't work.
Basically, what I would like to do is, I'd like to create a custom attribute that will provide me to choose if to save property to the elasticsearch or not.
So, I have a SaveUserProcessLog method.
Then I create a custom attribute named as MyProcessLogDetailAttribute and inherited from nest's StringAttribute:
[AttributeUsage(AttributeTargets.Property)]
public class MyUserProcessLogDetailAttribute : StringAttribute
{
public MyUserProcessLogDetailAttribute(bool SaveProperty)
{
Ignore = !SaveProperty; //when true ignore is false
}
}
And I am adding this attribute to the properties which I want to be saved in.
[MyUserProcessLogDetail(SaveProperty:false)]
public Guid UserCode { get; set; }
[MyUserProcessLogDetail(SaveProperty:false)]
public string FullName { get; set; }
Is inheriting from Nest's attribute approach right?
Why am I not using the original [String(Ignore=false/true)] attribute of Nest is because I may want to create a new attribute to save property for another method. For instance, don't save UserCode for UserProcessLog() method but save for SaveUserAmendments().
I hope I have been clear about this.
Thanks for your help in advance.