如何将动态sql表调用成WEB API [英] How to call dynamic sql table into WEB API

查看:253
本文介绍了如何将动态sql表调用成WEB API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI团队

Greenting!

Greenting!

我有一个SQL表,其中添加了列 由每天运行一次的工作动态生成。现在我需要使用WEB api中的GET方法通过存储过程调用此动态表,并使用HTML,Boot Starp和JSON在Web页面中显示它们。

I have an SQL table where columns are added  dynamically by a job which runs daily once. Now I need to call this dynamic table with data through stored procedure using GET method in WEB api and Show them in Web page using HTML, Boot Starp and JSON.

我正在使用ADO。 net在我的WEB API中。直到现在我已经修复了列,所以我创建了具有属性的模型并返回它们。现在我没有得到如何编写控制器并使用WEB API中的ADO .net调用SP。请帮我。这是我的表看起来如何

I'm using ADO .net in my WEB API. Till now i've alll fixed columns so i created models with attributes and returning them. now I'm not getting how to write a controller and call the SP using ADO .net in WEB API. Please help me. Here is how my table looks

AFTER连接类型列可能会增加tommarow。和上面相同的表我需要在网页上显示,请帮我这个如何在所有3层中编码

AFter join type columns may increase tommarow. and the same table as above i need to show in Webpage, Please help me for this how to code in all 3 layers

谢谢

Sundari

Sundari

推荐答案

如果你有SQL版本2016或更新版本,你可以使用FOR JSON查询提示,它将你的查询输出格式化为JSON文档。

If you have SQL version 2016 or newer, you can use the FOR JSON query hint which would format your query output as a JSON document.

这样,您的.NET应用程序将始终只从数据库中接收一个列,您只需将JSON结果直接转发到WEB API,然后让客户端层解析结果。

This way your .NET application will always receive only one single column from the database, and you can simply forward the JSON result directly to the WEB API and let the client layer parse the results.

这篇关于如何将动态sql表调用成WEB API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆