Skip to main content
anaximander's user avatar
anaximander's user avatar
anaximander's user avatar
anaximander
  • Member for 10 years, 10 months
  • Last seen more than a month ago
awarded
revised
Remove unwanted characters from a string
deleted 3 characters in body
Loading…
awarded
comment
Entity Framework query optimization
Move the .ToList() in ShowController.UserShows() to after the .Select(). The ToList() enumerates the results, so what you're doing is pulling all the data in, then projecting it into viewmodels. Do it the other way round, and it'll get SQL to do the projecting, and pull in only what it needs. As a general rule, do .ToList() as late as possible.
comment
Simple foreach adding to a list
You can do the .SelectMany() immediately; no need to .Select() it and then .SelectMany() the result.
comment
Generating a URL
Please tell me you aren't sending user credentials as URL parameters. Even if it's not over the internet. Even if it's not actually across a network, but just localhost. That password will be in the clear, in log files, in multiple places, several of which are not generally protected. User credentials should be sent in the body, over a properly-secured connection, using TLS.
awarded
awarded
comment
Remove unwanted characters from a string
@Liren same effect from opposite routes. The .Contains() is checking "does that collection contain this character" while the .Any() is checking "are any of the characters in this collection the same as this one". They end up doing the same thing, but you're doing with .Where() and .Any() is to manually do what .Contains() is actually intended for.
comment
Remove unwanted characters from a string
True, but I tend to work with arrays when going back and forth between string and a bunch of chars. No real reason; mostly just because there's a specific ToCharArray() and out of left-over habits from other languages.
awarded
revised
Remove unwanted characters from a string
added 25 characters in body
Loading…
awarded
answered
Loading…
comment
Hello World, Phrancis
@JeroenVannevel I would argue that the exception to that rule is when the class represents a string-like thing, like a StringBuilder, or some sort of character array. In that case, toString() is a logical choice for getting the resultant string.
awarded
awarded