Paolo ponzano - 142 - Feb 17, 2014

I think there’s a bug on how SS OrmLite handles null values…
I’ve a POCO like

 public class SomeDTO : IReturn<bool>
        public int ID { get; set; }
        public int? OptionalID { get; set; }

when I pass to ORMLite the field as null it generates the following statement

exec SP_xxx @ID=1602,OptionalID=default

If I set it as DBNull.Value it correctly hands null value… on StackOverflow there was an iussue #274 on this …wasn’t it supposed to be fixed?

Are you calling a stored procedure? what’s the failing test look like?

paolo ponzano:

Yes it’s a procedure … I’m calling it as

 var lst = db.Exec(dbCmd =>
                    dbCmd.CommandType = CommandType.StoredProcedure;
                    dbCmd.CommandText = storedProcedure;

                    dbCmd.Parameters.Add(new SqlParameter(“ID”, request.ID));
                    dbCmd.Parameters.Add(new SqlParameter(“OptionalID”, request.OptionalID)); //this sets default
                 return dbCmd.ExecuteNonQuery();

Your executing plain ADO.NET code at this point. OrmLite has no impact here.

paolo ponzano:

Ah ok…I’m using this way since with db.SqlProcedure I don’t know where to set the SP name…

Here are some examples calling SQL Server procs with the Sql* apis:

Here’s an example using the ExecuteProcedure method:
It uses the name of the DTO - but the Sql* APIs offer more flexibility.