StoredProcedure parameters have changed type

It's been happening now for a number of version updates. I want to say this goes back to about version 2.66. When I do an database infer, all my previously working stored procedure calls which included a date now fail. I get the following message:
cannot convert from 'System.DateTime' to 'string'

My database is SQL Server. The stored procedures haven't changed, meaning the parameters are set as DateTime. However the function calls generated by Radzen are now setting the parameter as a string. Why the change? Do I have to go into 50+ lines to change the datetime variable to a string? This is actually pretty urgent right now as I have to make changes to the application, but I don't want to have to wade in and make all these changes for something that was working perfectly fine previously.

We are not aware of such issue. Please send us your stored procedure definition to test it locally, in the meantime you can download and use the version of Radzen that works properly.

script.zip (2.9 KB)

I've attached a script that builds out the tables required for the stored procedure GetVoidPayments. Let me know if you require more. I'll gladly provide it.

Here is what is currently being generated for that stored procedure, you can see that the 2 date fields are set as strings and that inside the function, those fields are being converted back to a DateTime object in the FromSqlRaw function

public async Task<IQueryable<Models.RecoDb.VoidPayment>> GetVoidPayments(int? ProgramID, string StartDate, string EndDate, Query query = null)
{
OnVoidPaymentsDefaultParams(ref ProgramID, ref StartDate, ref EndDate);

      var items = Context.VoidPayments.FromSqlRaw("EXEC [dbo].[VoidPayments] @ProgramID={0}, @StartDate={1}, @EndDate={2}", ProgramID, string.IsNullOrEmpty(StartDate) ? DBNull.Value : (object)DateTime.Parse(StartDate, null, System.Globalization.DateTimeStyles.RoundtripKind), string.IsNullOrEmpty(EndDate) ? DBNull.Value : (object)DateTime.Parse(EndDate, null, System.Globalization.DateTimeStyles.RoundtripKind)).ToList().AsQueryable();

      if (query != null)
      {
          if (!string.IsNullOrEmpty(query.Expand))
          {
              var propertiesToExpand = query.Expand.Split(',');
              foreach(var p in propertiesToExpand)
              {
                  items = items.Include(p);
              }
          }

          if (!string.IsNullOrEmpty(query.Filter))
          {
              if (query.FilterParameters != null)
              {
                  items = items.Where(query.Filter, query.FilterParameters);
              }
              else
              {
                  items = items.Where(query.Filter);
              }
          }

          if (!string.IsNullOrEmpty(query.OrderBy))
          {
              items = items.OrderBy(query.OrderBy);
          }

          if (query.Skip.HasValue)
          {
              items = items.Skip(query.Skip.Value);
          }

          if (query.Top.HasValue)
          {
              items = items.Take(query.Top.Value);
          }
      }
      
      OnVoidPaymentsInvoke(ref items);

      return await Task.FromResult(items);
  }

I'm unable to find version of Radzen that supported DateTime type for stored procedure parameters. I've tested several old versions including one of the last versions for 2021 and parameters where always strings. Can you point us when this worked according to your expectations? I've tested even last version for November 2021

Yep, I had a version saved that I had to previously roll back to. It was 2.66.0.

Looking at it I understand what changed. It wasn't the actually Radzen storedprocedure function that changed. It was how the parameter was sent. So here's what it looks like in 2.66.0
var recoDbGetVoidPaymentsResult = await RecoDb.GetVoidPayments(selectedProgram, $"{selectedStartDate}", $"{selectedReportDate}");
getDataList = recoDbGetVoidPaymentsResult;

And here's what it looks like now.
var recoDbGetVoidPaymentsResult = await RecoDb.GetVoidPayments(selectedProgram, selectedStartDate, selectedReportDate);
getDataList = recoDbGetVoidPaymentsResult;

Here's a screenshot of the storedprocedure being called through the Handler. It doesn't change between the 2 versions, however the way the call is created does.

We've fixed this issue and the fix will be part of our next update before the end of the week.

1 Like

You guys are amazing!

Btw. you can use the latest Radzen if you fix your data source meta by removing format from the DateTime stored procedure parameters: