• c#泛型&使用示例


    附上参考学习代码

    using DbOperate.Modify;
    using Model;
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Web.Http;
    using Utils.Log4net;
    using Utils.JsonXmlHelper;
    using static Model.GetUsrUserModel.OutGetUsrUserModel;
    
    
    namespace AssistServer.Controllers
    {
        public class GetUsrUserController : ApiController
        {
            /// <summary>
            /// 获取用户信息
            /// </summary>
            /// <param name="{"ActionCode":"1001","Table":[{"COMPNO":"*","USR":"0001"}]}"></param>
            /// <returns></returns>
            [TransLogFilter]
            public Object Post([FromBody]string sJson)
            {
                LogHandle.WriteLog(typeof(GetUsrUserController),1,sJson);
                InValueModel<List<GetUsrUserModel.InGetUsrUserModel.Table>> InValueModel = SerializationHelper.Deserialize<InValueModel<List<GetUsrUserModel.InGetUsrUserModel.Table>>>(sJson);
                String ActionCode = InValueModel.ActionCode.ToString();
                OutValueModel<List<Table>> OutValueModel = new OutValueModel<List<Table>>();
                List<Table> Table = new List<Table>();
                try
                {
                    String COMPNO = InValueModel.Table[0].COMPNO.ToString();
                    String USR = InValueModel.Table[0].USR.ToString();
                    String sSql = "Select CompNo,Usr,Name,Pwd From tUsrUser_App " +
                                  "Where CompNo='" + COMPNO + "' and Usr = '" + USR + "'";
                    DataTable DtHead = DbModify.GetDataTable(sSql);
                    Table = DbModify.GetDataList<Table>(sSql);
                    if (Table.Count != 0)
                    {
                        OutValueModel.RtnCode = "1";
                        OutValueModel.Msg = "获取用户信息成功";
                    }
                    else
                    {
                        OutValueModel.RtnCode = "0";
                        OutValueModel.Msg = "无此用户信息";
                    }
                    OutValueModel.Table = Table;
                }
                catch (Exception ex)
                {
                    OutValueModel.RtnCode = "-1";
                    OutValueModel.Msg = "获取用户信息失败"+ex.Message;
                }
                LogHandle.WriteLog(typeof(GetUsrUserController), 1, SerializationHelper.Serialize(OutValueModel));
                return OutValueModel;
            }
    
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace Model
    {
        public class InValueModel<T>
        {
    
            public String ActionCode { get; set; }
    
    
            public T Table { get; set; }
    
    
        }
    }
    using System;
    
    
    
    namespace Model
    {
        public class GetUsrUserModel
        {
            //用户信息入参
            public class InGetUsrUserModel
            {
                public class Table
                {
                    public String COMPNO { get; set; }
    
                    public String USR { get; set; }
                }
            }
            //用户信息返回结果
            public class OutGetUsrUserModel
            {
                public class Table
                {
                    public String COMPNO { get; set; }
    
                    public String USR { get; set; }
    
                    public String NAME { get; set; }
    
                    public String PWD { get; set; }
                }
            }
        }
    }
  • 相关阅读:
    DRF(Django-Rest-FrameWork)非主外键自关联
    用 django orm 写 exists 条件过滤
    算法模板:堆,最小生成树(Prim,Kruskal),快速幂
    算法模板:快速排序,欧拉筛法
    算法模板:大数乘法,并查集
    算法模板:动态规划(背包问题)
    算法模板:贪心
    算法模板:尺取法,前缀和,差分数组
    Vala之入门篇(二)Vala安装
    Vala之入门篇(一)Vala简介
  • 原文地址:https://www.cnblogs.com/guoqiang1/p/8301792.html
Copyright © 2020-2023  润新知