public override string Build() { Add(Tab(2), string.Format("public static {0} Create({0} template)", EntityName)); Add(Tab(2), "{"); Add(Tab(3), string.Format("return Create(template, {0});", Settings.IsRecursiveCrud.ToString().ToLower())); Add(Tab(2), "}", NewLine()); Add(Tab(2), string.Format("public static {0} Create({0} template, bool isAddChildren)", EntityName)); Add(Tab(2), "{"); Add(Tab(3), "var returnValue = new ", EntityName, "()"); Add(Tab(3), "{"); AddFieldAssignments(); Add(Tab(3), "};", NewLine()); if (Navigations.Any() || CollectionNavigations.Any()) { Add(Tab(3), "if(isAddChildren)"); Add(Tab(4), "AddChildrenForCreate(returnValue, template);", NewLine()); } //if (IsRoot) // Add(Tab(3), "context.", EntityNamePluralized, ".Add(returnValue);", NewLine()); Add(Tab(3), "return returnValue;"); Add(Tab(2), "}", NewLine()); return(base.Build()); }
public override string Build() { if (!Navigations.Any() && !CollectionNavigations.Any()) { return(string.Empty); } AddUpdateChildren(); if (InnerContainer.Length == 0) { //return string.Empty; } else { InnerContainer.Remove(InnerContainer.Length - 2, 2); } Add(Tab(2), string.Format("private void UpdateChildren({0} template)", EntityName)); Add(Tab(2), "{"); Add(false, InnerContainer.ToString()); Add(Tab(2), "}", NewLine()); return(base.Build()); }
public override string Build() { Add(Tab(2), string.Format("public void Update({0} template)", EntityName)); Add(Tab(2), "{"); Add(Tab(3), string.Format("Update(template, {0}, {0}, {0});", Settings.IsRecursiveCrud.ToString().ToLower())); Add(Tab(2), "}", NewLine()); Add(Tab(2), string.Format("public void Update({0} template, bool isUpdateChildren, bool isAddChildren, bool isDeleteChildren)", EntityName)); Add(Tab(2), "{"); AddFieldAssignments(); if (Navigations.Any() || CollectionNavigations.Any()) { Add(); Add(Tab(3), "if(isUpdateChildren)"); Add(Tab(4), "UpdateChildren(template);", NewLine()); Add(Tab(3), "if(isAddChildren)"); Add(Tab(4), "AddChildrenForUpdate(template);", NewLine()); Add(Tab(3), "if(isDeleteChildren)"); Add(Tab(4), "DeleteChildrenForUpdate(template);"); } //if (IsRoot) // Add(NewLine(), Tab(3), "context.", EntityNamePluralized, ".Update(this);"); Add(Tab(2), "}"); return(base.Build()); }
private void BuildConstructor() { if (!CollectionNavigations.Any() || IsEnumeration) { return; } Add(Tab(2), string.Format("public {0}{1}()", EntityName, Settings.ContractName)); Add(Tab(2), "{"); CollectionNavigations.Each(n => { var type = Singularize(Pass.Code.Escape(n.ToEndMember.GetEntityType())); Add(Tab(3), Pass.Code.Escape(n), " = new List<", type, Settings.ContractName, ">();"); }); Add(Tab(2), "}"); }
private void BuildConstructor() { Add(Tab(2), "public ", EntityName, "()"); Add(Tab(2), "{"); Add(Tab(3), "Initialize();"); if (CollectionNavigations.Any() && !IsEnumeration) { Add(); CollectionNavigations.Each(n => { var type = Singularize(Pass.Code.Escape(n.ToEndMember.GetEntityType())); Add(Tab(3), Pass.Code.Escape(n), " = new List<", type, ">();"); }); } Add(Tab(2), "}"); }