如何通过使用ASP.NET核心2.1传递表名来获取表中的字段? [英] How to get fields exist on table by passing table name by using ASP.NET core 2.1 ?

查看:56
本文介绍了如何通过使用ASP.NET核心2.1传递表名来获取表中的字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过传递表名来获取表中的字段?



假设我在SQL Server 2012上有表名Employee



这是Employee Table EmployeeCode,EmployeeName ,, ..等字段



如何使函数通过到它的表名,它将检索字段或列为



EmployeeCode,



EmployeeName



我在网络API核心项目上工作,角度为7



功能结构如下



我的尝试:



public List< string> GetColumnNames(string tablename)

{

}

解决方案

ANSI SQL查询语句为:

  SELECT  Column_Name  FROM  Information_Schema.Columns < span class =code-keyword> WHERE  Table_Name = '  tableName' 


How to get fields exist on table by passing table name ?

suppose I have table name Employee on SQL server 2012

and this is fields of Employee Table EmployeeCode,EmployeeName,,..etc

How to make function pass to it table name and it will retrieve fields or columns as

EmployeeCode,

EmployeeName

I work on web API core project with angular 7

structure of function as below

What I have tried:

public List<string> GetColumnNames(string tablename)
{
}

解决方案

The ANSI SQL query statement for this is:

SELECT Column_Name FROM Information_Schema.Columns WHERE Table_Name = 'tableName'


这篇关于如何通过使用ASP.NET核心2.1传递表名来获取表中的字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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