For specific needs, please see the previous blog: DDD Domain driven design practice of how to extract the model, the following is a specific entity, aggregation, value object code, do not want to say what is the entity, aggregation and other concepts, believe that the theory of things we have known. I am curious about ddd, not in real project practice, and even did not see the real DDD Practice project source code, in an extremely tangled state, or even unable to extricate themselves, so caution ddd enthusiasts, if you want to practice in the project DDD, Unless you have a good understanding of entity modeling and domain responsibilities (many times you will struggle with the logic where it is, the design problem) and your team level is highly agreeable to DDD, otherwise please be careful ... Don't spray!
After the code, please see the demo result chart first
1, the aggregation of the base class, note that almost the attribute is the first letter of Pinyin name, do not spray Kazakhstan, do not digress!
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks; Using DDD.
infrastructure; Using DDD.
Infrastructure.domain; Namespace DDD. Domain {///<summary>///Project base class///</summary> public abstract class Projectbase:entitybase, Iaggregateroot {protected projectbase () {this.
ND = DateTime.Now.Year; This.
CJSJ = DateTime.Now; This.
WH = new Documentnumber ();
///<summary>///Schedule Batch///</summary> public int APPC {get; set;}
<summary>///project name///</summary> public string Xmmc {get; set;}
<summary>///Project number///</summary> public string Xmbh {get; internal set;}
<summary>///Annual///</summary> public int ND {get; set;} <summary>//////</summary> public documentnumber WH {get; set;}
<summary>///creation time///</summary> public DateTime CJSJ {get; set;}
<summary>///issued the administrative name///</summary> public string XFXZQMC {get; set;}
<summary>///issued the Administrative Code///</summary> public string XFXZQDM {get; set;}
<summary>///Administrative name///</summary> public string XZQMC {get; set;}
<summary>///Administrative Code///</summary> public string XZQDM {get; set;}
<summary>///Memo///</summary> public string BZ {get; set;}
<summary>///Indicator level///</summary> public indicatorgrade zbjb {get; set;}
<summary>///Attachment ID///</summary> Public decimal Attachid {get; set;}
<summary>///project Status///</summary> public projectstauts status {get; set;} <summary>///Business code///</summary> protected abstract String Bussinesscode
{get;}
<summary>///Registration///</summary>///<param name= "seq" ></param> public virtual void Register () {this. Xmbh = this.
Bussinesscode + seqgeneratr.generate (); ///<summary>///can update or delete///</summary>///<returns></re turns> Public virtual bool CanUpdate () {return this. ZBJB = = Indicatorgrade.country | | This. XFXZQDM = = this. XZQDM | | This.
Status = = Projectstauts.default; public void Send () {this.
Status = projectstauts.sent; }
}
}
2, aggregate 1
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks; Using DDD.
infrastructure; Using DDD.
Infrastructure.domain; Namespace DDD. Domain.indicator {///<summary>///program Metrics///</summary> public class PLANINDICATOR:PROJECTB
ASE {public planindicator () {Indicatorarea = new Indicatorarea ();
} protected override string Bussinesscode {get {return ' 103101 ';} ///<summary>///Metric area///</summary> public Indicatorarea Indicatorar
EA {get;
Set public override Ienumerable<businessrule> Validate () {if (this. INDICATORAREA.GD > this.
INDICATORAREA.NYD) {yield return to new Businessrule ("indicatorarea.gd", "arable land can not be greater than the area of farmland");
}
} public override void Register () {if (this. ZBJB = = indicatorgrade.country) {this.
Send (); Base.
Register (); }
}
}
3, polymerization 2