扩展函数不能返回空值 [英] Extension functions cannot return null values

查看:63
本文介绍了扩展函数不能返回空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述










我在biztalk地图中使用下面的脚本functoid将字符串转换为DateTime

   public     DateTime      ConvertOpenDate    string   openDate   < span class ="pln"> 
{
DateTime oDate ;
< span class ="kwd"> if (! DateTime TryParseExact openDate " yyyy-MM-DD HH:mm:ss.fff" 系统 全球化 CultureInfo InvariantCulture 系统 全球化 DateTimeStyles out oDate ))
{
return null ;
}
else
{
返回 oDate ;
}
}

但它抛出错误说


扩展函数不能返回空值。


如何处理这个问题。我将日期时间插入MS SQL DB

解决方案

所以,让我说,这使得这种方式变得更加复杂是的。


我在另一个帖子中准确地解释了你需要做什么。 使用扩展方法确实无法获得任何结果。


您需要做的就是返回'o'格式以填充SQL模式中的xs:datetime字段。



I am using the below scripting functoid in the biztalk map to convert the string in to DateTime

public  DateTime? ConvertOpenDate(string openDate)
  {
    DateTime oDate;
        if (!DateTime.TryParseExact(openDate, "yyyy-MM-DD HH:mm:ss.fff", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out oDate))
         {
            return null;
        }
       else
        {
            return oDate;
        }
   }

But it is throwing error saying

Extension functions cannot return null values.

How to handle this. I am inserting the datetime in to MS SQL DB

解决方案

So, let me say, this is making this way more complicated then it needs to be.

I explained exactly what you need to do in the other thread.  Using an extension method really doesn't get you anything.

All you need to do is return the 'o' format to fill an xs:datetime field in the SQL Schema.


这篇关于扩展函数不能返回空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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