HOw would I make the above code return bool based on the execution. So i can return to the calling method.
public void UpdateSpanStartDate(SpanRecord spanRecord)
{
Run(conn => conn.Execute("[dbo].[SpecailSpanStartUpdate]",
new DynamicParameters(new Dictionary<string, object>
{
{"SpanId", spanRecord.SpanId},
}), null,Config.CommandTimeout, CommandType.StoredProcedure));
}
That depends entirely on where the bool
is meant to be coming from. The most common setup would be for the sproc to select
some kind out output; if this is the case, the most appropriate thing to do is to use Query<T>
along with a LINQ operation such as Single
. For example (also tidying up the parameters):
Run(conn => conn.Query<int>("[dbo].[SpecailSpanStartUpdate]",
new {spanRecord.SpanId}, null,
Config.CommandTimeout, CommandType.StoredProcedure).Single() != 0);
Here I'm expecting a single row that has an int
in the first column, returning true
if the int
is non-zero.