使用委托给方法 开始和结束注入代码

//------------------------------------------------------------------------------
// <auto-generated>
//     此代码由工具生成。
//     运行时版本:4.0.30319.42000
//
//     对此文件的更改可能会导致不正确的行为,并且如果
//     重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------

namespace IOT.MIS.Model
{
	using System;


	[System.SerializableAttribute()]
	public class Root
	{

		public Root()
		{
			this.state = 1;
		}
		/// <summary> 
		/// 列表对象 List<entity>
		/// </summary>
		public Object rows { get; set; }
		/// <summary>
		/// 0 失败 ; 1 成功
		/// </summary>
		public int state { get; set; }
		/// <summary>
		/// 数据的总行数
		/// </summary>
		public int total { get; set; }
		public string errMsg { get; set; }


	}
}

  

//封装注入方法
public Root BllFunc(Action ro)
		{
			Root root = new Root();
			try
			{
				ro();//.Invoke();
				root.state = 1;

			}
			catch (Exception ex)
			{
				ex.SaveEx(root);

			}
			return root;
		}

  

//调用
///  <summary>
		///   修改
		///  </summary>
		public Root UpdatePartnerInfo(PartnerInfo partnerInfo)
		{
			return BllFunc(new Action(() =>
			   {
                                   //执行代码
				   var dao = GetIOT_IDao();
				   dao.UpdatePartnerInfo(partnerInfo);
			   }));

		}

  

猜你喜欢

转载自www.cnblogs.com/wlzhang/p/10795877.html