Marks an action to be performed in a property setter before the value is written to the backing store.
Syntax
Example
C# | Copy Code |
---|
public partial class Customer {
// Sample signatures for a BeforeSet method for any Customer property
// (invoked for both simple and navigation properties).
// Additional signatures are possible.
// Signature 1 - accept a property value and return a property value.
// Any value returned is passed to next action.
[BeforeSet]
public object BeforeSetAnyCustomerProperty1(object value) {
Console.WriteLine("Before setting a customer property 1");
return value;
}
// Signature 2 - accept a property value, but no return value.
[BeforeSet]
public void BeforeSetAnyCustomerProperty2(object value) {
Console.WriteLine("Before setting a customer property 2");
}
// Signature 3 - accept base IPropertyInterceptorArgs.
// Allows you to cancel further actions and modify the Value.
// No property information available.
[BeforeSet]
public void BeforeSetAnyCustomerProperty3(IPropertyInterceptorArgs args) {
Console.WriteLine("Before setting a customer property 3");
}
// Signature 4 - accept EntityProperty interceptor arguments.
// The arguments passed allow you to determine the property retrieved
// and to cancel the set. args.Value can be modified.
// args.VerificationSetterOptions allows verification options to be set for all subsequent
// actions within the setter. Note that verification can be turned off also.
[BeforeSet]
public void BeforeSetAnyCustomerProperty4(IEntityPropertySetInterceptorArgs args) {
Console.WriteLine("Before setting a customer property 4");
}
// Signature 5 - accept strongly-typed IPropertyInterceptorArgs.
// Same features as IPropertyInterceptorArgs but Instance is now strongly-typed.
[BeforeSet]
public void BeforeSetAnyCustomerProperty5(IPropertyInterceptorArgs<Customer, object> args) {
Console.WriteLine("Before setting a customer property 5");
}
} |
Remarks
Inheritance Hierarchy
Requirements
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family
See Also