Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 忽略缺少的列_C#_Asp.net_Sql Server 2008_Ibatis - Fatal编程技术网

C# 忽略缺少的列

C# 忽略缺少的列,c#,asp.net,sql-server-2008,ibatis,C#,Asp.net,Sql Server 2008,Ibatis,如何忽略iBatis resultMap上缺少的列 如果我有这个制图器 <resultMap id="DBEntity" class="CS_Entity"> <result property="Id" column="Id" /> <result property="Field1" column="f1" /> <result property="Field2" column="f2" /> </resultMap&

如何忽略iBatis resultMap上缺少的列

如果我有这个制图器

<resultMap id="DBEntity" class="CS_Entity">
    <result property="Id" column="Id" />
    <result property="Field1" column="f1" />
    <result property="Field2" column="f2" />
</resultMap>

对于某些查询,我希望返回f2列,但如何在不为所有其他查询添加带有默认值的字段f2的情况下声明呢


有一种方法吗?

使用两个结果映射一个与
f2

<resultMap id="DBEntityWithF2" class="CS_Entity">
    <result property="Id" column="Id" />
    <result property="Field1" column="f1" />
    <result property="Field2" column="f2" />
</resultMap>
<resultMap id="DBEntity" class="CS_Entity">
    <result property="Id" column="Id" />
    <result property="Field1" column="f1" />
</resultMap>
您只需在sql中使用
“从表中选择f2作为字段2”
,并使用
resultClass=“CS_Entity”
而不是在配置中使用
resultMap
。这样,您就不必像上面那样声明映射了