2

我已将问题隔离到调用存储过程的 BOM 方法中的以下代码行:

        if ((includeAgeSeventeenAndUnder == CodeFluentPersistence.DefaultBooleanValue))
        {
            return null;
        }
        if ((includeAgeEighteenAndOver == CodeFluentPersistence.DefaultBooleanValue))
        {
            return null;
        }

因为 CodeFluentPersistence.DefaultBooleanValue 等于 False。每当将 false 参数传递给该方法时,该方法就会退出并返回 null。我怎样才能防止这种情况?

4

1 回答 1

2

我通过将 modeNullable 设置为 true 来使其工作。

<cf:method name="Load">
  <cf:body text="LOADONE(date  startDate, date endDate, bool includeAgeSeventeenAndUnder, bool includeAgeEighteenAndOver,int sisProgramId) RAW  " rawText="This has been deleted because it is not relevent to question" language="tsql" />
  <cf:parameter typeName="bool" name="includeAgeSeventeenAndUnder" modelNullable="True" />
  <cf:parameter typeName="bool" name="includeAgeEighteenAndOver" modelNullable="True" />
</cf:method>

Meziantou 建议实际上更可取,因为我真的不希望参数可以为空。下面的代码片段演示了禁用默认值检查的正确方法。

<cf:method name="Load">
  <cf:body text="LOADONE(date  startDate, date endDate, bool includeAgeSeventeenAndUnder, bool includeAgeEighteenAndOver,int sisProgramId) RAW  " rawText="This has been deleted because it is not relevent to question" language="tsql" />
  <cf:parameter typeName="bool" cfom:checkDefaultValue="false" name="includeAgeSeventeenAndUnder" modelNullable="False" />
  <cf:parameter typeName="bool" cfom:checkDefaultValue="false" name="includeAgeEighteenAndOver" modelNullable="False" />
</cf:method>
于 2015-12-03T20:19:52.310 回答