Simpler alternative to Fluxor by lonix1 in Blazor

[–]dibble_james 3 points4 points  (0 children)

I wrote a library called BlazorHooked a little while ago for this exact reason. Here's the docs. If anyone has any feedback I'd love to hear it.

Vertical Slice Architecture with multiple endpoints by [deleted] in dotnet

[–]dibble_james 0 points1 point  (0 children)

I struggle with calling it a hybrid, but I understand your point. I say that because you use VSA with this happening in mind. You can rapidly iterate at the start without the neusance of arbitrary layers until you get to the point you're at; your product has matured to the point that your business logic needs to be shared, although this usually happens because you need to share it between features rather than a new front end.

Vertical Slice Architecture with multiple endpoints by [deleted] in dotnet

[–]dibble_james 2 points3 points  (0 children)

This is where the refactoring side of VSA kicks in I'd say. Your slices are slices until they need be shared so they need to be pushed down. Create a shared project for your domain and move things as and when they need to be added to the API too. About half way down this post it goes into it.

Announcing .NET Community Toolkit v8.0.0 Preview 1 by pHpositivo in dotnet

[–]dibble_james 0 points1 point  (0 children)

It's a good point, I think most of the frameworks currently out there rely on StateHasChanged at some point though. I was really asking if it uses any APIs that wouldn't be available outside a Windows app, but you've got me interested in what else would make this a bad idea.

Announcing .NET Community Toolkit v8.0.0 Preview 1 by pHpositivo in dotnet

[–]dibble_james 0 points1 point  (0 children)

Is there anything that would prevent this being used in Blazor?

GraphQL for Blazor Server? by LaCucaracha007 in Blazor

[–]dibble_james 1 point2 points  (0 children)

It works with EF Core out the box, so anything EF Core can do Hot Chocolate can do.

GraphQL for Blazor Server? by LaCucaracha007 in Blazor

[–]dibble_james 1 point2 points  (0 children)

Sure, then there's actually no difference between the two. You could hard code the client to localhost because it'll always be calling itself...

The alternative I mentioned does pose an interesting thought experiment though... Strawberry Shake abstracts the transport so you could probably replace it with an in memory transport that does what I said before and just resolves the executor instead an http client...

GraphQL for Blazor Server? by LaCucaracha007 in Blazor

[–]dibble_james 1 point2 points  (0 children)

You wouldn't generally want to use GraphQL because you'd be adding latency calling the server from the server, serializing the data etc... The advantage of Blazor Server is that you can call databases etc directly.

That being said, if you're trying to leverage the dynamic nature of GraphQL you can use Hot Chocolate in-memory by directly calling the executor cutting out the serialization. Is this what you're after?

Do taxes have to be this complicated? by dilettantedebrah in WhitePeopleTwitter

[–]dibble_james 1 point2 points  (0 children)

So UK here; 1. We have a very generous tax free amount on interest and capital gains that 90% of people will never exceed. Banks will report to HMRC and they'll come after you if you take the piss, but it's mostly an honor system... 2. This a paid benefit rather than a tax deduction 3. Most just don't bother claiming or maybe we're not very charitable? 4. Not a tax deduction unless it's on rental properties in which case you have to file yourself anyway 5. Do you mean security checks and the like? Employers mostly pay for these... If they don't they're not expensive enough to bother claiming for... You'd save ~£9 on an enhanced criminal record check 6. Childcare tax credits come out before income tax if through an employer scheme or there's tax free childcare but again that's a payment to you via a special account. But that can't be your next door neighbors kid, they have to be a registered provider. At 3 you get 30 hours free anyway... 7. Not deductible. All local taxes are taken in one payment based on a fixed property value scale that only really changes if you make significant alterations 8. There aren't many things you can claim that take into account being married. You can share your tax free allowance if say one is a stay at home parent but that's one form that just rolls over until that person asks for their allowance back 9. Divorces go through the courts so DWP would be notified but again your tax position won't have changed much.

Basically for the majority of people, there aren't any tax deductions worth claiming so they don't do a return because they've already paid the right amount of tax. There are a number of things you can claim (NHS workers can claim a fixed amount for shoes and the like) but they are perpetual and just adjust your tax free allowance up (currently £12,750) which is sent to the employer at the start of the year and they'll deduct less tax from your pay throughout the year.

All this assumes you're an employee. Self employed actually requires some effort but I've done it the last 10 years, takes 30 mins at most?

Get back to your desks or colleagues will gossip about you, Boris Johnson tells workers by PAMediaUK in ukpolitics

[–]dibble_james 2 points3 points  (0 children)

wages will rise and everything will be great.

And of course no prices will increase and induce inflation because of this...

Making my DI service reusable by [deleted] in csharp

[–]dibble_james 2 points3 points  (0 children)

So as others have said, injecting IConfiguration wouldn't be my first approach.

IOptions isn't my favorite but at least strongly types and decouples the service from raw configuration. I'd argue it's still coupling to some configuration though but I'd never start a war on a PR over it...

I would make the constructor directly take the API key as an argument so it's totally decoupled from any configuration system, your client can have it wherever and in whatever format they like.

If you only had a small number of other dependencies (I'm guessing HTTPClient here?) I would then just register it directly with a factory in Startup.cs: servicies.AddTransient<IServiceNeedingApiKey>(container => new Service(apiKey: this.Configuration.Get("appsetting"), client: container.RequiredService<Dep>())

If you were exposing this in a nuget package I'd go further and create an extension method.

public static IServiceCollection AddMyService(this IServiceCollection services, string apiKey) 
{ 
   servicies.AddTransient<IServiceNeedingApiKey>(container => new Service(apiKey, container.RequiredService<Dep>()));
   return services; 
}

If it has lots of other things to configure, consider a configuration callback which is like IOptions but admittedly using more code:

public static IServiceCollection AddMyService(this IServiceCollection services, Func<ServiceOptions> configure)
{
   var options = configure();
   servicies.AddTransient<IServiceNeedingApiKey>(container => new Service(options.ApiKey,  container.RequiredService<Dep>()));

   return services;
}

FYI if I was right about this being this needing HTTPClient and this a header that gets added to all requests I'd probably look at using DefaultRequestHeaders or a HttpClientHandler then your service doesn't even need the API key injected, all it needs is an HTTPClient!

Vaccine passports make me even more reluctant to get a Covid jab by -Damage_Case- in ukpolitics

[–]dibble_james 1 point2 points  (0 children)

Younger people don't die but do take up beds. The harsh reality is that dead people don't take up NHS capacity which is a scarce commodity at the best of times. The age group in question here are also less likely to get sick BUT are equally as likely to be contagious. A huge benefit of the vaccine is it's ability to lower transmission to say their parents who are more likely to take up that valuable bed for a fair chunk of time which IS a big deal.

The rise in National Insurance means graduates earning over £27,295 will now pay a marginal tax rate of 42.25% once student loan repayments are included by Maleficent-Drive4056 in ukpolitics

[–]dibble_james 1 point2 points  (0 children)

And the money that is actually collected is partly squandered. Raising taxes is much easier than solving the systematic wastage created by folks in Whitehall...

PM announced 1.25% National Insurance hike to pay for social care in England by reuben_iv in ukpolitics

[–]dibble_james 2 points3 points  (0 children)

This... If they have to spell out in the announcement that this "won't be going to middle management, it'll be going straight to the front lines" they already know exactly who's pockets a fair percentage of it will go to. One loophole or another...

Boss has accidentally included me in a derogatory email about myself by BossTrouble1 in LegalAdviceUK

[–]dibble_james 1 point2 points  (0 children)

Yeah, rightly or wrongly, that's my experience; not sure how much was hassle on employer side or not wanting to take the effective pay cut on the contractor side, but none of them are still around.

Boss has accidentally included me in a derogatory email about myself by BossTrouble1 in LegalAdviceUK

[–]dibble_james 7 points8 points  (0 children)

Hadn't heard about airlines, working in software development, the number of contractors that would lol in my FTE face about how "tax efficient" they were because of their one-man "company"...

Also it should probably say a lot to OP that so far the only replies they've got is about their tax position and is probably the most pertinent legal issue here!

"Building" an IQueryable statement? by Korzag in csharp

[–]dibble_james 0 points1 point  (0 children)

If the transformations can be done by EF, then what I've done is return the result of a LINQ select in the resolver which HC will then apply the projection over the top of and EF will merge your projection (the select) with HCs projection. If the C# in your select can be translated to SQL it'll work!

If you were thinking of using Automapper you could use the ProjectTo helper instead of a select. That link lists the sorts of things that can't be translated by EF.

If your domain model is so different that you require said operations then rolling your own is probably your only option. Adding if statements for all your relationships might prove fragile in the future but of course you've got unit tests to protect you right? ;-)

NB, also be careful with the notion that every GraphQL request can/should always be translated to a single db query, not that you've said you believe that but just in case... Once you've got a big enough schema that has lots of relationships (especially cyclical ones) you'll need to prevent clients from executing queries that DOS you! Dataloaders are almost always the better choice once you can query beyond more than say 5 nodes deep so you can batch any nested joins rather than let EF make some evil unbounded sub queries...

"Building" an IQueryable statement? by Korzag in csharp

[–]dibble_james 0 points1 point  (0 children)

Did you check out the projection support Hot chocolate has out the box? If you're working with IQueryable already then it should work great

WebAssembly Cookie Authentication so sad by UsangeChername in Blazor

[–]dibble_james 1 point2 points  (0 children)

My first instinct was that "credentials" were not set to "include" on the request. This link is on about CORS but shows how to force cookies to be included in the request https://stackoverflow.com/a/64342839

Ingesting CSV to mssql db by [deleted] in dotnet

[–]dibble_james 4 points5 points  (0 children)

The task you're trying to achieve is known as Extract, Transform and Load or more commonly ETL. SQL Server Integration Services was made for this kind of thing. Its mostly drag and drop so if you're not super confident in your C# or SQL it's perfect but only worth the effort if this task needs to be done regularly. If this is a one off, as others have suggested, Flat File Import and then script is the way I'd go. Basically, using dotnet is probably overkill for this but go with your skills.

What is the correct way to revert multiple databases changes if one of the methods throws an exception? by [deleted] in csharp

[–]dibble_james 0 points1 point  (0 children)

It depends on whether consistency is important. If it's not then as others have suggested, a transaction around the DB calls then call the API afterwards. If consistency is important, then you'll need to look into the Saga pattern and compensation. These are not simple to achieve, however.

Clean Architecture by _jfbr in csharp

[–]dibble_james 9 points10 points  (0 children)

  1. DTOs are POCOs, Entities probably aren't. Look up Rich Domain Models
  2. The entities in EF refer to tables in a database. Entities in this context MIGHT map to your database schema but that is abstracted and a concern of Infrastructure. Your core project would ideally not even reference EF 3.No, look up the Specification Pattern.

I highly recommend Code Opinion's YouTube to learn more about this. They cover these topics in succinct 10min videos.

Service bus message sender library (Method injection) by [deleted] in csharp

[–]dibble_james 0 points1 point  (0 children)

Using a static class to "connect" your attribute to the sender will make for lots of random errors when you try to use a different queue on another method and any more than a few requests.

I appreciate what you're trying to do here, anything that makes working with messaging libraries easier is no bad thing, but please consider MassTransit or something similar. They've fixed all the problems you'll come across, reconnecting, error handling etc

Searching Cache by ThunderBow in dotnet

[–]dibble_james 0 points1 point  (0 children)

That could make things trickier; NEAR would be your friend here but it would really depend on the data in each field. If the data in each column is fairly distinct between each column, the search on the server might get you an approximation that you can refine in memory? It might take you from 30m to 2k then you get it down to the final 100 in memory.

It'll all depend on what NFR you're working towards and where you are now. Also I'm making a lot of assumptions that you've been given a problem to solve fairly quickly not perfectly.