0

I'm doing something completely normal - registering Insight.Database autointerfaces in WebApi DI.

Here's the code -

var dataString = builder.Configuration.GetConnectionString("DefaultConnection");

SqlInsightDbProvider.RegisterProvider();
var connection = new SqlConnection(dataString);
builder.Services.AddTransient(thing => connection.AsParallel<IUserData>());
builder.Services.AddTransient(thing => connection.AsParallel<IRoleData>());

And I'm getting this bizarre error at the point where the injected interfaces are used in a controller.

wierd error message

And there's no documentation on it. Nothing has changed from other projects where it works perfectly fine. It's just... broken.

Any help would be hugely appreciated

Editing to add stack trace

Stack Trace

Rich Bryant
  • 865
  • 10
  • 27
  • So what is the exception call stack? What happens when you ignore it? (as in continue running the application, not placing try/catch) – Zdeněk Jelínek Jul 11 '22 at 08:27
  • You can't ignore it, or if you do then the swagger page still shows as before. The call stack is the usual gibberish and far too long for a comment. – Rich Bryant Jul 11 '22 at 08:30
  • 2
    Based on stacketrace it looks like an issue within `SqlInsightDbProvider` regarding some code generation. – Guru Stron Jul 11 '22 at 09:26
  • It's very odd. I created another project that simply read and wrote to the database using identical code and that works fine – Rich Bryant Jul 11 '22 at 10:14
  • 2
    **DO NOT post images of code, data, error messages, etc.** - copy or type the text into the question. [ask] – Rob Jul 12 '22 at 00:49

1 Answers1

0

Inevitably, the problem turned out to be between keyboard and chair.

I was attempting to structure my returns from the database using Insight's [Recordset] attributes like so...

[Recordset(1, typeof(UserClaim), GroupBy = nameof(UserClaim.UserId), Into=nameof(ApplicationUser.UserClaims))]

except I'd forgotten to specify the relationship type. So amending this on all applicable calls to

[Recordset(1, typeof(UserClaim), IsChild = true, GroupBy = nameof(UserClaim.UserId), Into=nameof(ApplicationUser.UserClaims))]

sorted it all out.

Rich Bryant
  • 865
  • 10
  • 27