OPC.UA.DAL/DALProcedureBase.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OPC.UA.Model;
using System.Reflection;
using System.Data;
using System.Data.SqlClient;

namespace OPC.UA.DAL
{
    public class DALProcedureBase<T> where T : ModelBase
    {
        public static void Execute(T info)
        {
            Type type = typeof(T);
            string pname = type.Name;//存储过程名称
            SqlManager manager = new SqlManager(pname, true);
            PropertyInfo[] pinfos = type.GetProperties();
            foreach (PropertyInfo item in pinfos)
            {
                ParameterInfoAttribute pattr = item.GetCustomAttributes(typeof(ParameterInfoAttribute), true)[0] as ParameterInfoAttribute;
                if (pattr.Direction == ParameterDirection.Input)
                {
                    object value = item.GetValue(info, null);
                    if (value != null)
                    {
                        manager.Add(item.Name, value);
                    }
                }
                else
                {
                    if (pattr.Size == 0)
                    {
                        manager.AddOutParament(item.Name, pattr.Type);
                    }
                    else
                    {
                        manager.AddOutParament(item.Name, pattr.Type, pattr.Size);
                    }
                }
            }
            SqlHelp.CUD(manager);
            //设置输出参数
            foreach (PropertyInfo item in pinfos)
            {
                ParameterInfoAttribute pattr = item.GetCustomAttributes(typeof(ParameterInfoAttribute), true)[0] as ParameterInfoAttribute;
                if (pattr.Direction == ParameterDirection.Output || pattr.Direction == ParameterDirection.InputOutput)
                {
                    item.SetValue(info, manager[item.Name].Value, null);
                }
            }
        }

        public static List<S> ExecuteSelect<S>(T info) where S : ModelBase
        {
            Type type = typeof(T);
            string pname = type.Name;//存储过程名称
            SqlManager manager = new SqlManager(pname, true);
            PropertyInfo[] pinfos = type.GetProperties();
后面还有 69 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。