CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
csla.netcore.test/Basic/Child.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="Child.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>no summary</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Collections.Generic;
10using System.Text;
11using System.Data;
12
13namespace Csla.Test.Basic
14{
15 [Serializable()]
16 public class Child : BusinessBase<Child>
17 {
18 private Guid _guid = System.Guid.NewGuid();
19
20 public static readonly PropertyInfo<string> DataProperty = RegisterProperty<string>(c => c.Data);
21 public string Data
22 {
23 get { return GetProperty(DataProperty); }
24 set { SetProperty(DataProperty, value); }
25 }
26
27 public Guid Guid
28 {
29 get { return _guid; }
30 }
31
32 public static readonly PropertyInfo<GrandChildren> GrandChildrenProperty = RegisterProperty<GrandChildren>(c => c.GrandChildren);
34 {
35 get { return GetProperty(GrandChildrenProperty); }
36 private set { LoadProperty(GrandChildrenProperty, value); }
37 }
38
39 [CreateChild]
40 private void Create([Inject] IChildDataPortal<GrandChildren> dataPortal)
41 {
42 GrandChildren = dataPortal.CreateChild();
43 }
44
45 [FetchChild]
46 private void Fetch(IDataReader dr, [Inject] IChildDataPortal<GrandChildren> dataPortal)
47 {
48 GrandChildren = dataPortal.CreateChild();
49 MarkOld();
50 }
51
52 [Update]
53 internal void Update(IDbTransaction tr)
54 {
55 if (IsDeleted)
56 {
57 //we would delete here
58 MarkNew();
59 }
60 else
61 {
62 if (IsNew)
63 {
64 //we would insert here
65 }
66 else
67 {
68 //we would update here
69 }
70 MarkOld();
71 }
72 }
73 }
74}
This is the base class from which most business objects will be derived.
Definition: BusinessBase.cs:38
Maintains metadata about a property.
static readonly PropertyInfo< GrandChildren > GrandChildrenProperty
static readonly PropertyInfo< string > DataProperty
Interface defining the members of the child data portal type.
@ Serializable
Prevents updating or inserting until the transaction is complete.