9using System.Collections.Generic;
15using System.Runtime.Serialization;
16using System.Threading.Tasks;
23 private static PropertyInfo<int> IdProperty = RegisterProperty<int>(c => c.Id,
"Id");
26 get {
return GetProperty(IdProperty); }
27 set { SetProperty(IdProperty, value); }
35 return LazyGetProperty(ChildListProperty, () => GetDataPortal<ChildList>().Create());
44 public class OneItem<T> : Rules.BusinessRule
47 protected override void Execute(Rules.IRuleContext context)
49 var target = (T)context.Target;
50 if (target.ChildList.Count < 1)
51 context.AddErrorResult(
"At least one item required");
58 ChildList.ListChanged +=
new System.ComponentModel.ListChangedEventHandler(ChildList_ListChanged);
59 this.ChildChanged +=
new EventHandler<ChildChangedEventArgs>(HasChildren_ChildChanged);
64 base.OnDeserialized(context);
65 ChildList.ListChanged +=
new System.ComponentModel.ListChangedEventHandler(ChildList_ListChanged);
66 this.ChildChanged +=
new EventHandler<ChildChangedEventArgs>(HasChildren_ChildChanged);
69 void ChildList_ListChanged(
object sender, System.ComponentModel.ListChangedEventArgs e)
76 BusinessRules.CheckRules(ChildListProperty);
80 private async Task Create()
82 await BusinessRules.CheckRulesAsync();
85 #region Private Helper Methods
92 private IDataPortal<T> GetDataPortal<T>() where T : class
94 return ApplicationContext.GetRequiredService<IDataPortal<T>>();
This is the base class from which most business objects will be derived.
Contains event data about the changed child object.
Maintains metadata about a property.
override void Execute(Rules.IRuleContext context)
override void Initialize()
override void AddBusinessRules()
override void OnDeserialized(StreamingContext context)
RelationshipTypes
List of valid relationship types between a parent object and another object through a managed propert...
@ Serializable
Prevents updating or inserting until the transaction is complete.