private string Get_GetAll() { string passValue = ""; foreach (var item in LstInfoTable) { string checkBool = item.GetTypeCs() == typeof(bool).ToString() ? "== true" : ""; passValue += $@" obj.{item.Name.Replace(' ', '_')} = item.{item.Name.Replace(' ', '_')} {checkBool} ;"; } foreach (var itemFK in Table.lstFK) { var tblJoin = new TableObject(itemFK.NameTableJoin, Connection); string sDto = Setting.GetClassDto(tblJoin.Name); string stableJoin = itemFK.IsPK ? "" : $"_{Setting.GetNameTable(tblJoin.Name)}Join"; string passValueJoin = ""; for (int i = 0; i < tblJoin.lstColumns.Count; i++) { var co = tblJoin.lstColumns[i]; string cm = i == tblJoin.lstColumns.Count - 1 ? "" : ","; string checkBool = co.GetTypeCs() == typeof(bool).ToString() ? "== true" : ""; string checkFK = stableJoin; string checkNullable = ""; string nameEntty = co.Name.Replace(' ', '_'); if (co.IsPK) { checkFK = ""; checkNullable = $"({co.GetTypeCs()})"; nameEntty = itemFK.Name.Replace(' ', '_'); } passValueJoin += $@" {co.Name.Replace(' ', '_')} = {checkNullable}item.{nameEntty}{checkFK} {checkBool} {cm}"; } passValue += $@" obj.{sDto}Join = new {sDto}() {'{'} {passValueJoin} {'}'}; "; } return($@" public List<{cDto}> {GetNameMethod(eMethod.GetAll)}() {'{'} var list = new {dbEntity}().{proc.GetName(eMethod.GetAll)[0]}(); List<{cDto}> lst = new List<{cDto}>(); foreach (var item in list) {'{'} var obj = new {cDto}(); {passValue} lst.Add(obj); {'}'} return lst; {'}'} "); }
public override string GetCode() { return($@" using System; using System.Collections.Generic; namespace {Setting.GetNamespaceDto(NameTable)} {'{'} public class {Setting.GetClassDto(NameTable)} {'{'} {GetFied()} {'}'} {'}'} "); }
private string GetFied() { string s = ""; foreach (var item in LstInfoTable) { s += $@" public {item.GetTypeCs()} {item.Name.Replace(' ', '_')} {'{'} get; set; {'}'}"; } foreach (var item in Table.lstFK) { var tblJoin = new TableObject(item.NameTableJoin, Connection); string sDto = Setting.GetClassDto(tblJoin.Name); s += $@" public {sDto} {sDto}Join {'{'} get; set; {'}'}"; } return(s); }
public Bus(string nameTable, SqlConnection connection, Setting setting) : base(nameTable, connection, setting) { cDto = Setting.GetClassDto(NameTable); cDal = Setting.GetClassDal(NameTable); }
public Dal(string nameTable, SqlConnection connection, Setting setting) : base(nameTable, connection, setting) { cDto = setting.GetClassDto(NameTable); proc = new Proc(sTable, connection, setting); dbEntity = new SqlConnectionStringBuilder(connection.ConnectionString).InitialCatalog + "Entities"; }
private string Get_GetBy() { var lsKey = LstInfoTable.Where(q => q.IsPK).ToList(); if (lsKey.Count < 1) { return(string.Empty); } string result = ""; for (int i = 0; i < lsKey.Count; i++) { var itemKey = lsKey[i]; string setValue = ""; foreach (var v in LstInfoTable) { string checkBool = v.GetTypeCs() == typeof(bool).ToString() ? "== true" : ""; setValue += $@" obj.{v.Name.Replace(' ', '_')} = item.{v.Name.Replace(' ', '_')} {checkBool} ;"; } foreach (var fk in Table.lstFK) { var tblJoin = new TableObject(fk.NameTableJoin, Connection); string sDto = Setting.GetClassDto(tblJoin.Name); string stableJoin = $"_{Setting.GetNameTable(tblJoin.Name)}Join"; string passValueJoin = ""; for (int j = 0; j < tblJoin.lstColumns.Count; j++) { var co = tblJoin.lstColumns[j]; string cm = j == tblJoin.lstColumns.Count - 1 ? "" : ","; string checkBool = co.GetTypeCs() == typeof(bool).ToString() ? "== true" : ""; string checkFK = stableJoin; string checkNullable = ""; string nameEntty = co.Name.Replace(' ', '_'); if (co.IsPK) { checkFK = ""; checkNullable = $"({co.GetTypeCs()})"; nameEntty = fk.Name.Replace(' ', '_'); } passValueJoin += $@" {co.Name.Replace(' ', '_')} = {checkNullable} item.{nameEntty}{checkFK} {checkBool} {cm}"; } setValue += $@" obj.{sDto}Join = new {sDto}() {'{'} {passValueJoin} {'}'}; "; } result += $@" public {cDto} {GetNameMethod(eMethod.GetBy)}{itemKey.Name}({itemKey.GetTypeCs()} {itemKey.Name}) {'{'} var list = new {dbEntity}().{proc.GetName(eMethod.GetBy)[i]}({itemKey.Name}); foreach (var item in list) {'{'} var obj = new {cDto}(); {setValue} return obj; {'}'} return null; {'}'} "; } return(result); }