检查对象属性是否有空值
2015-09-14 10:54
435 查看
public ActionResult Create(crm_CompetitiveProducts cp) { using (var db = new BaseDbContext()) { PropertyInfo[] propertys = cp.GetType().GetProperties(); int a = 0; foreach (var i in propertys) { if (i.GetValue(cp) == null) { a = a + 1; } } if (a == 0) { db.Insert<crm_CompetitiveProducts>(cp); } else { this.ShowMessage("信息不全", "录入失败"); return RedirectToAction("Create"); } return RedirectToAction("Index"); } }
相关文章推荐
- 浅谈JAVA集合框架
- hdu 5438 Ponds 2015长春网络赛 图论 dfs bfs
- 如何安装nginx第三方模块--add-module
- 一些有用的linux命令
- STL源码剖析 [简单应用总结二]
- WinForm中AssemblyInfo.cs文件参数具体讲解
- hydra 密码破解工具详解
- linux下mysql安装、目录结构、配置
- Linux 重定向
- 基于Java的打包jar、war、ear包的作用与区别详解
- 斯坦福大学Andrew Ng教授主讲的《机器学习》公开课观后感
- 关于MD5的软件
- 嵌入式系统概念学习
- sping 一些使用
- xtreme toolkit pro——CXTPReportControl控件教程-2
- IOS Not a PNG file iOS 真机上报错
- 【Unity】NGUI自制 Scroll View实现触摸滚动相册效果
- docker1.7 api
- POM要怎么写
- Citrix归档