实体框架中的可选列 [英] Optional columns in Entity Framework

查看:71
本文介绍了实体框架中的可选列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我开始将ADO.net应用程序移植到Entity Framework。我的表中有一些可选列。使用ADO.net,我只检查列是否存在,如果存在则获取值。

Recently I started porting ADO.net app to Entity Framework. There are some optional columns in my table. With the ADO.net, I just check for existence of the column and get the value if it is there.

if (MyTable.Columns.Contains("PerformPreCheck") && 
    DBNull.Value != MyRow[MyTable.Columns["PerformPreCheck"]]) 
{ 
         m_bPerformPreCheck = (bool)MyRow[MyTable.Columns["PerformPreCheck"]]; 
} 

如何使用Entity Framework实现相同的目标?

How can I achieve the same thing with Entity Framework?

谢谢你,Suresh

Thank you, Suresh

推荐答案

在什么情况下你不知道你是否正在处理一个具有特定列的表?
Under what circumstances would you not know if you are dealing with a table with a specific column?


这篇关于实体框架中的可选列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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