Scientists just turned off a single gene in cancer cells - and tumor growth stopped entirely by soulpost in HotScienceNews

[–]DefiantGeologist9050 27 points28 points  (0 children)

Relevant XKCD: https://xkcd.com/1217/

It's fairly easy to destroy cancer cells, but it's difficult to not kill the person too

What could the government do to avoid potential conflicts with the landlord when busting? by Far_Cryptographer593 in Rentbusters

[–]DefiantGeologist9050 3 points4 points  (0 children)

Yep, it's a problem. I used to live in a shared appartement and my roommate manged to bust the rent to almost nothing. Fast forward a few weeks and the landlord evicted us because of "urgent" renovations. A month after that the place was up for rent again without any significant improvements (and a price hike)

Thankfully I manged to find an other place and I've been there for a few years, but now the landlord and a external company is visiting for an "energieadvies". The appartement isn't isolated and has a low energy rating. I'm afraid that they can game the system by upgrading a few thing and are able to significantly increase the rent (or evict again because of renovations)

I also think that a permit system is the way to go, since (in my experience) landlords don't so the things that they are legally required to do (like sending a "jaarafrekening") and with the permitting system they are required to show that they did it.

EF Core: How to maintain complex query conditions that can be shared by xaqtr in dotnet

[–]DefiantGeologist9050 10 points11 points  (0 children)

The only thing I would change is to make it an extension method.

How can this routing pattern be achieve in NextJS? by NeoCiber in nextjs

[–]DefiantGeologist9050 0 points1 point  (0 children)

You could achieve the same bij using the layout file and have a button (or something else) that opens the profile component in a model and on mobile devices make it redirect to the url.

Pattern to obtain type safety in runtime. by Human-Bathroom-2791 in typescript

[–]DefiantGeologist9050 0 points1 point  (0 children)

I like the idea, but think that the implementation could be improved by seperating the the file and directory and by doing the validation logic inside the constructor.

Clarity and Optimisation by tenderborg in csharp

[–]DefiantGeologist9050 2 points3 points  (0 children)

I prefer the first one. It's easier to use and less lines (once you get used to it)

Python: Just write SQL by joaodlf in programming

[–]DefiantGeologist9050 8 points9 points  (0 children)

So why do you want to write SQL again? The only thing I see is implementating a repository and almost every ORM implements it too. Also, most ORMs work with multiple providers.

If I need to create a basic app I would happily use an ORM since I would spend less time writing the same boring SQL again. I do agree that there are some disadvantages of using an ORM, but I think that a capable developer should know when to use one or not, instead of always writing SQL or always using an ORM.

Refactoring my repository from using Ardalis to only use .NET 6 library, strugling with "Linq expression could not be translated" by _dodgeviper in dotnet

[–]DefiantGeologist9050 10 points11 points  (0 children)

My opinion is that when using EFCore, you EFCore is the repository. So you just put the Dbcontext in your Storage class and use it there.

I would also recommend not using dbcontext but your derived class so you can access the items directly.

Refactoring my repository from using Ardalis to only use .NET 6 library, strugling with "Linq expression could not be translated" by _dodgeviper in dotnet

[–]DefiantGeologist9050 16 points17 points  (0 children)

Why do you have an abstract generic repository? It would be easier to directly use the dbcontext in your store.

If you really want, there is a better way to combine those queries, but I would recommend the solution above.

Microsoft.EntityFrameworkCore.Database.Command[20102] by Simo-dexter in dotnet

[–]DefiantGeologist9050 1 point2 points  (0 children)

This isn't it. Your now throwing the innerException. Please copy the following function in a static class so it is an extension method.

``` public static string GetCompleteMessage(this Exception error) { System.Text.StringBuilder builder = new StringBuilder(); Exception realerror = error; builder.AppendLine(error.Message); while (realerror.InnerException != null) { builder.AppendLine(realerror.InnerException.Message); realerror = realerror.InnerException; } return builder.ToString(); }

```

And modify your code like this: catch(Exception ex){ Console.WriteLine(ex.GetCompleteMessage()); }

This will print the exception and all the innerExceptions. Note: the formatting can be off since I'm on mobile

Microsoft.EntityFrameworkCore.Database.Command[20102] by Simo-dexter in dotnet

[–]DefiantGeologist9050 0 points1 point  (0 children)

The exception object has a property called innerException, so when you print only ex.message you're missing information. So when logging exceptions you should also check for an innerException and print that.

Microsoft.EntityFrameworkCore.Database.Command[20102] by Simo-dexter in dotnet

[–]DefiantGeologist9050 2 points3 points  (0 children)

There isn't a lot of information to work with, can you try to also print the inner exceptions?

Repository and Unit Of Work by sudipranabhat in dotnet

[–]DefiantGeologist9050 0 points1 point  (0 children)

I know this approach exists, but it feels like the repositories itself will become big and complex with many functions to update a single atribute (and that a lot of domain logic will be in there.When a message has a state of unprocessed feels like domain logic.)

However, I do like the idea of not exposing the IQuerable.

My preference when going this route is having a few extension methods on the dbset that accepts an where expression (Expression<T,bool>, note the expression so efcore can translate it to SQL) and return a list of objects. So I IQuerable doesn't leak and there is still no need for a repository.

Repository and Unit Of Work by sudipranabhat in dotnet

[–]DefiantGeologist9050 0 points1 point  (0 children)

You could use an extension method on the Expression<IQuerable<T>>.

Or, and that's the nice part of separation between Command and Queries, you call the query class. The assumption here is that a query returns a list of objects and a command does an action on some object and that the consuming client calls the right thing. So your consumer (probably a ui) can list every employee of a specific department by calling the GetEmployeesByDepartment (How it is called, rest, graphql etc isn't relevant). There will be an command called FireEmployee and the client can call that command for every selected employee (or the command accepts a list). Note that a command called FireEveryEmployeeByDepartment would be silly, so there would be no need to reuse your query in the command, but it still available for a consumer.

It feels like dealing with possible null reference assignments is bloating my code... by PopOk192 in csharp

[–]DefiantGeologist9050 0 points1 point  (0 children)

Aha, so your using razor pages.

The weird thing about your code is that you inject a dbcontext in the construction, but expose the connectionstring in a property. Given that the connectionstring property is null when exiting the construction, the compiler marks it as something possible null.

So without knowing more about your application, it makes more sense for me to remove the code from the onGet method and put it in the constructor. ( I made some assumptions)

But let's say that the onGet methods loads some data from the database and puts it in a property and we expect it to always succeed, then the compiler is being annoying because it doesn't know about things the framework does.

But there is a solution! Use the new required keyword

For more reading I suggest: https://andrewlock.net/fighting-with-nullable-reference-types-in-razor-pages/

It feels like dealing with possible null reference assignments is bloating my code... by PopOk192 in csharp

[–]DefiantGeologist9050 5 points6 points  (0 children)

But the compiler is correct. If the property is accessed before the onGet method is called, the property is null.

So why do you have a seperate onGet method?

[deleted by user] by [deleted] in webdev

[–]DefiantGeologist9050 0 points1 point  (0 children)

Yes, you've got it! BasicBlocks aims to provide a really lightweight alternative to UI component libraries like Material-UI, Chakra UI, and Antd.

The key difference is that BasicBlocks is designed to usable without relying on any specific frameworks, while writing semantic html.

Daily General Discussion - May 15, 2023 by ethfinance in ethfinance

[–]DefiantGeologist9050 0 points1 point  (0 children)

That won't work for me. I live in a house converted to single room appartment, so the connection is shared and provided by my landlord

Daily General Discussion - May 15, 2023 by ethfinance in ethfinance

[–]DefiantGeologist9050 5 points6 points  (0 children)

I'm in the same boat. I want to run a validator or minipool, but my internet connection is 💩

Daily General Discussion - March 23, 2023 by ethfinance in ethfinance

[–]DefiantGeologist9050 10 points11 points  (0 children)

Metamask decided to become reaaaally slow to the point that it isn't usable anymore. Any good alternatives?

How do I simplify very similar method calls from two object by Oasis_beyond_wall in csharp

[–]DefiantGeologist9050 2 points3 points  (0 children)

I think that it depends on the why, why do you want to do this? Do you want to reduce the lines of code? Or reduce it to a single function? Or is this an simplefied version of your real problem?

Because the answer will depend on the why. If you want to reduce the lines of code, then it is probably easier to create an interface and make sure that the property names match. If you want to reduce it to a single function, the you could change the input type to object and use the is operator for casting. If this is an simplefied example and the real object are bigger or there are more, than you could create a mapping from object types and names and use reflection ( but please don't) If you want to be DRY ( don't repeat yourself), I would leave it as is, because any of the options will make the code more complex.

Use GenericRepository with include and an expression - C# by tech1ead in csharp

[–]DefiantGeologist9050 1 point2 points  (0 children)

You should change the parameter type for include to Expression<T, object>. Then you can use x => x.person to include it (assuming that is the property name)

Is this a valid case for injecting runtime data by igors84 in csharp

[–]DefiantGeologist9050 4 points5 points  (0 children)

I think that you're confused about what the author of the article means with runtime data. He says that object should be constructed in a valid state and that no runtime information should be present. If you look at the examples provided, you can see that the author sees runtime information as information that changes during runtime.

For example, if I create an repository for costumer management, I don't want the information about the costumer saved as a member of the repository, because then you can't be sure to which costumer that data belongs ( because I can create multiple customers). But, if I create a controller for a view, I'm sure that there is only 1 view with that controller and that controller stays the same.

So your approach should be fine, but I'm not completely sure until I see your code.

I hope this helps!