Pagano
Custom Made Collection
I guess this is a real stupid question but how do I create my own custom collection?
I have a
Player
class and I need to create a custom class that is a Collection of Player with other fields and methods but how do I implement my own collection in .NET Core?
If I had to guess, I would say implement IEnumerable<T>
and IEnumerator<T>
but I don't know how to implement them either. Can I have some help please?
I can provide with a more in-depth of the idea and my classes if needed.103 replies
Beginner in EF Core and SQL Server in need for help
Hello, I am new here but I needed some help using my project. I need to connect to a SQL Server DB using .NET Core with EF Core. This is a simple example of my problem:
This would be the table mapped to a C# class, right? However, I need to work with User objects to perform methods and have fields that need to have private setters and getters etc. How would I do that? I was told to user another class like this to wrap around UserModel:
But I ended up in an unsolved problem. When using my code I will work with User objects, right? But I have some questions surrounding this idea (if the best - correct me please if there is any better way).
1) How do I create an instance of User if I don't have a UserModel object? 2) When adding a new UserModel to the DB, how do I do it if I am using User objects throughtout the project, not UserModel objects?Probably dumb questions but basically, how I keep alternating between their uses? There is probably a better way to do it. If so, please I want to do this the best way possible. I am new to EF Core and SQL Server in general but willing to learn anything to make my project the best version possible.
5 replies