如何获取entityframework中的entity的列名
来源:互联网 发布:免备案一级域名 编辑:程序博客网 时间:2024/05/16 02:35
try this by using LINQ-TO-OBJECT to find out all the properties, and then use GetCustomAttributes to find out which fits well.
通过GetProperties()方法获取列名list,即linq to sql 语句获取;
namespace nibian{ /// <summary> /// Suppose this is a class that has two "Required" attributes /// </summary> public class Model { [Required] public int Id { get; set; } [Required] public string Name { get; set; } public double Score { get; set; } } public class MainTest { static void Main(string[] args) { // This will search for each Attributes applied onto the property // to find out whether "Required" exists or not. var properties = typeof(Model).GetProperties().Where(p => p.GetCustomAttributes(typeof(RequiredAttribute), false).Length==1).Select(p=>p); // This will output the Name of the assigned public properties. foreach (var item in properties) { Console.WriteLine(item.Name); } } }}
- 如何获取entityframework中的entity的列名
- oracle 如何获取表的主键列名,如何获取表的所有列名
- oracle 如何获取表的主键列名,如何获取表的所有列名 .
- 获取数据表的列名
- 获取datatable的列名
- 获取datagridview某列的列名
- 获取泛型列表中的列名
- MS SQL中怎么获取某个数据库的各个表名及表中的列名
- 如何取出DataTable中的列名
- hibernate 获取实体的表名、主键名、列名
- 如何获取java类中的变量名的字串
- EntityFramework获取数据库的时间
- 获取DataGridView 列名的方法
- excel 获取最后一列的列名
- 获取数据库中表的列名
- 获取一个表的所有列名
- sql中获取表的列名
- python获取Oracle的列名
- AAA与Radius
- Edo与银行联手推与地理位置相关的购物新模式
- 分布式拒绝服务攻击(DDoS)原理及防范(1)
- 去掉Iframe的横向或竖向滚动条
- 23种设计模式简介(转载)
- 如何获取entityframework中的entity的列名
- 登录FTP脚本
- HDU_1853 Cyclic Tour KM
- (转)频繁分配释放内存导致的性能问题的分析
- 顺时针打印矩阵(面试宝典)
- 站点改进心得--CSS、JS在不同浏览器的兼容性问题 - []
- 使用java接口或则java抽象类
- 50款CSS工具
- 迷雾中挣扎