❔ best design practice for this?
Hi everyone. I have a ConvertedRequest class that acts as an Entity Framework model for the database. Inside the class, there is an ID of type string (I want it to be alphanumeric 6 digits, not GUID). I have a method to generate this below. My question is what's the best design practice to reference this method? I am technically not gonna make more "Random" value methods, so was thinking static singleton, but the purpose of this project is to learn how to write with good design patterns
Including it in the Controller for the API just seems ugly and out of place
2 Replies
Either make it a singleton and inject it with DI, or make it an extension method of
Random
Or, hell, just a random static method also works
Just make sure to use Random.Shared
in that case, to avoid new
ing up the random each timeWas this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.