Quantcast
Channel: EntityFramework Reverse POCO Code First Generator
Viewing all articles
Browse latest Browse all 1642

New Post: GetValueOrDefault with nullable DateTime Stored Procedure parameters

$
0
0
My AppendFormat line is currently as follows:
sb.AppendFormat(
    isNullable
        ? "            if (!{0}.HasValue){1}                {0}Param.Value = DBNull.Value;{1}{1}"
        : "            if ({0}Param.Value == null){1}                {0}Param.Value = DBNull.Value;{1}{1}",
    p.NameHumanCase, Environment.NewLine);
Which produces:
var beginningDateParam = new SqlParameter 
{
    ParameterName = "@Beginning_Date",
    SqlDbType = SqlDbType.DateTime, 
    Direction = ParameterDirection.Input,
    Value = beginningDate.GetValueOrDefault() 
};
if (!beginningDate.HasValue)
    beginningDateParam.Value = DBNull.Value;

Viewing all articles
Browse latest Browse all 1642

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>