Tvde1
Tvde1
CC#
Created by Faker on 2/19/2025 in #help
✅ is there a difference between NET core and .NET and .NET framework ?
.NET Framework was the first to exist. It is Windows only. In 2016, Microsoft decided to rewrite it and make it cross platform. That new codebase was called .NET Core As of 2021, .NET core is renamed to .NET> So: * .NET = Newest version (use this) * .NET Core = 2016-2021, deprecated * .NET Framework = Windows only, used for legacy systems
6 replies
CC#
Created by Faker on 2/19/2025 in #help
✅ is there a difference between NET core and .NET and .NET framework ?
It is not "important" per se to know how they differ. Just know that .NET is the current version, and .NET Core and .NET Framework are older and have their limitations, but might still be used by companies
6 replies
CC#
Created by felsokning on 1/30/2025 in #help
Populate `EnvelopeRecipientCollection` on `Recipients` Property of a `MailItem` in Transport Agent
I would build a layer between this external API and your business logic. That way you can test your business logic without needing to construct external models
14 replies
CC#
Created by felsokning on 1/30/2025 in #help
Populate `EnvelopeRecipientCollection` on `Recipients` Property of a `MailItem` in Transport Agent
Is there a reason you are trying to work with classes that are from an external library? I feel like you should not be unit testing those
14 replies
CC#
Created by Faker on 1/18/2025 in #help
✅ Taking user input using Console.ReadLine()
Some people have different tastes, but the majority of people use var whenever possible
44 replies
CC#
Created by Faker on 1/18/2025 in #help
✅ Taking user input using Console.ReadLine()
You have the option to write down the type, or to type var and let the compiler pick the type based on the what the function returns
44 replies
CC#
Created by Quantix on 1/11/2025 in #help
"Correct" way of setting up DB for Aspire.NET MicroServices following CA
Each microservice should be responsible for its own database, so there shouldn't be a microservice initializing the other databases
18 replies
CC#
Created by Jiry_XD on 11/18/2024 in #help
✅ Changing ASPNETCORE_ENVIRONMENT causes broken site.
I don't remember. Something like "blazor empty page ASPNETCORE_ENVIRONMENT"
8 replies
CC#
Created by Jiry_XD on 11/18/2024 in #help
✅ Changing ASPNETCORE_ENVIRONMENT causes broken site.
Yay!
8 replies
CC#
Created by Jiry_XD on 11/18/2024 in #help
✅ Changing ASPNETCORE_ENVIRONMENT causes broken site.
8 replies
CC#
Created by nathanAjacobs on 10/6/2024 in #help
Is it necessary to setup validation constraints at the api level and database level?
Unique constraints on database level are still useful for concurrency issues or if a bug in the business logic exists
6 replies
CC#
Created by Julian on 7/17/2024 in #help
Hook into job state change in HangFire
Just curious, what do you want to achieve with this?
6 replies
CC#
Created by Adam on 6/27/2024 in #help
Making my functions more generic
you have your ) a bit misplaced
return statsDB.Stats
.Where(s => s.PrimaryTags.Contains(tagName))
.ToList();
return statsDB.Stats
.Where(s => s.PrimaryTags.Contains(tagName))
.ToList();
24 replies
CC#
Created by Adam on 6/27/2024 in #help
Making my functions more generic
It's a bit strange why there would be things missing but alright 😁
24 replies
CC#
Created by Adam on 6/27/2024 in #help
Making my functions more generic
This one is fine
24 replies
CC#
Created by Adam on 6/27/2024 in #help
Making my functions more generic
if you wanted to, it would look something like
interface ITaggable
{
public string TagName { get; }
public string Name { get; }
}

public Dictionary<string, T> StatsWithTag<T>(DbSet<T> dbSet, string tagName)
{
return dbSet
.Where(stat => stat.TagName == tagName)
.ToDictionary(stat => stat.Name);
}

class Stat : ITaggable
{
// your properties
public string StatName { get; set; }
...

// required because of the interface
public string TagName { get; }

// Required so the interface can get the name
public string Name => StatName;
}

class SomethingElse : ITaggable
{
// your properties
public string MySomethingName { get; set; }
...

// required because of the interface
public string TagName { get; }

// Required so the interface can get the name
public string Name => MySomethingName;
}
interface ITaggable
{
public string TagName { get; }
public string Name { get; }
}

public Dictionary<string, T> StatsWithTag<T>(DbSet<T> dbSet, string tagName)
{
return dbSet
.Where(stat => stat.TagName == tagName)
.ToDictionary(stat => stat.Name);
}

class Stat : ITaggable
{
// your properties
public string StatName { get; set; }
...

// required because of the interface
public string TagName { get; }

// Required so the interface can get the name
public string Name => StatName;
}

class SomethingElse : ITaggable
{
// your properties
public string MySomethingName { get; set; }
...

// required because of the interface
public string TagName { get; }

// Required so the interface can get the name
public string Name => MySomethingName;
}
than you can do
var statsByName = StatsWithTag(statsDB.Stats, "my-tag");
var othersByName = StatsWithTag(statsDB.SomethingElse, "my-other-tag");
var statsByName = StatsWithTag(statsDB.Stats, "my-tag");
var othersByName = StatsWithTag(statsDB.SomethingElse, "my-other-tag");
But I wouldn't make it more complicated than it needs to be
24 replies
CC#
Created by Adam on 6/27/2024 in #help
Making my functions more generic
for your use case I wouldn't deduplicate it
24 replies
CC#
Created by Adam on 6/27/2024 in #help
Making my functions more generic
only when you do * ToList() * ToDictionary() * First() etc, does your query get executed. So any .Where() that you do, will be translated to SQL for better performance
24 replies
CC#
Created by Adam on 6/27/2024 in #help
Making my functions more generic
it is a little bit complicated, but in this case, the LINQ is more performant. Your example does: 1. Get all Stats from the database 2. Loop over all the stats 3. If it matches the tag name, add to dictionary The example I showed uses IQueryable, which entity framework is built on to do the following 1. Only take from the database, all the Stats which match the tag name. (This will do the query:
SELECT * FROM Stats
WHERE TagName = 'your-tag-name'
SELECT * FROM Stats
WHERE TagName = 'your-tag-name'
2. it loops over only the results which are found and makes a dictionary
24 replies
CC#
Created by Adam on 6/27/2024 in #help
Making my functions more generic
and it is recommended to make this async, but I will leave this up to you
24 replies