.net 如何在一个接口返回结果后调用一个方法

using System;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
using System.Web.Http;
using System.Data;
using System.Text;

using Test.Handler;

namespace Test
{
[RoutePrefix("api/Test")]
public class TestController : ApiController
{
private delegate void Log();

private void InsertLog()
{
string sql = string.Format("insert into Log(Time)values('{0}')",DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
DataCommon.DB().ExecuteSql(sql);
}

[Route("Test")]
public DataTable GetTable()
{
string sql = string.Format(@"select * from ProInfo");
DataTable ddt = DataCommon.DB().GetDataTable(sql);//获取工程信息
Log log = new Log(InsertLog);
//log.BeginInvoke(null, log);我希望在查询返回数据后执行InsertLog方法,请问一下该怎么做
return ddt;
}
}
}

你是弄webapi。你的需求有点阁僚,一般不会这么处理业务的。1、可以数据库底层触发;2、机构函数里面,在返回数据前调用函数;3、在客户端访问接口后,再调用一个接口。你说的问题比较模糊,不知道你要完成什么功能。扣我329399491我的

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答