Пример #1
0
        //        private string Get_DeleteBy()
        //        {
        //            if (LstInfoTable.Count(q => q.isKey) < 2) return string.Empty;
        //            var lstKey = LstInfoTable.Where(q => q.isKey).ToList();
        //            string param = null;
        //            string value = null;
        //            string result = "";
        //            foreach (var item in lstKey)
        //            {
        //                value = item.Name;
        //                param = $"{item.GetTypeCs()} {item.Name}";
        //                result += $@"
        //public bool {GetNameMethod(eMethod.DeleteBy)}{item.Name}({param})
        //{'{'}
        //    return new {cDal}().{GetNameMethod(eMethod.DeleteBy)}{item.Name}({value});
        //{'}'}
        //";
        //            }
        //            return result;
        //        }

        private string Get_Update()
        {
            if (!LstInfoTable.Any(q => q.IsPK) || LstInfoTable.Count == LstInfoTable.Count(q => q.IsPK))
            {
                return(string.Empty);
            }
            return($@"
public int Update({cDto} ob)
{'{'}
    return new {cDal}().{GetNameMethod(eMethod.Update)}(ob);
{'}'}
");
        }
Пример #2
0
        private string Get_Update()
        {
            if (!LstInfoTable.Any(q => q.IsPK) || LstInfoTable.Count == LstInfoTable.Count(q => q.IsPK))
            {
                return("");
            }
            string passValue = "";
            bool   isFirst   = true;

            foreach (var item in LstInfoTable)
            {
                string s = isFirst ? "" : ",";
                passValue += $@"{s} ob.{item.Name.Replace(' ', '_')} ";
                isFirst    = false;
            }
            return($@"
public int {GetNameMethod(eMethod.Update)}({cDto} ob)
{'{'}
    return new {dbEntity}().{proc.GetName(eMethod.Update)[0]}({passValue});
{'}'}
");
        }
Пример #3
0
        private string Get_Delete()
        {
            if (!LstInfoTable.Any(q => q.IsPK))
            {
                return(string.Empty);
            }
            var    lstKey  = LstInfoTable.Where(q => q.IsPK).ToList();
            string param   = null;
            string value   = null;
            bool   isFirst = true;

            if (lstKey.Count > 1)
            {
                foreach (var item in lstKey)
                {
                    string s = isFirst ? "" : ",";
                    value  += s + item.Name;
                    param  += $"{s}{item.GetTypeCs()} {item.Name}";
                    isFirst = false;
                }
            }
            else
            {
                foreach (var item in lstKey)
                {
                    string s = isFirst ? "" : ",";
                    value  += s + item.Name;
                    param  += $"object {item.Name}";
                    isFirst = false;
                }
            }
            return($@"
public int {GetNameMethod(eMethod.Delete)}({param})
{'{'}
    return new {cDal}().{GetNameMethod(eMethod.Delete)}({value});
{'}'}
");
        }