The only thing is, assume this is a massive database table, then it's copying the entire table into memory. Isn't this very bad performance-wise?
Probably still better than letting it excecute the same query 3 times, cause in theory it's possible that between excecution of the queries the...
Thanks for the explanation! So as you suggest, I could use ToArray(), or ToList() and this wil execute the query one time and then this generared array is used in the view. But it's not that this is bad practice or something?
I'm building a very simple CRUD web-application (ASP.NET MVC) for tennisplayers and the tournaments they can participate.
On a specific page I want to show all tournaments in the database with a title at the top op the page 'All Tournaments' with between brackets the amount of records in the...
Hi everyone,
I'm making a very simple CRUD console application using EF and sqlite.
I have 3 domain model classes, being: Player, Tournament and TournamentEnrollment
public class Player
{
[Key]
public int Id { get; set; }
[Required]
public string...
You put me on the right track and after looking it in some more detail, it's indeed one of the tasks of the ORM (in this case EF) to initialize the navigation properties when they are not already initialized.
I also learned that even when you don't make a DbSet for one of your domain models, but...
I have a question regarding navigation properties in EF and it's initialization. I created a small case to clarify the issue I'm dealing with. Sorry for the extreme long post but I like to be clear :).
Under my InMemoryRepository class I created 2 lists, being ‘Tickets’ and ‘TicketResponses’...
I'm following a EF Core (beginners) course and there is something I don't understand.
Below you can find the most important classes of a little excercise we got, to get to know EF core and the intent.
public class Student
{
public int StudentId { get; set; }
public string...
Hi everyone!
I want to use the n-layer architecture for a very simple CRUD console application. I have a domain layer, presentation layer (a console application), a business layer and a data acces layer.
If I'm right, the DAL is used to interact with a database, and the BL is a layer between the...
I'm new to the SRP, and quite a newbie :). But imagine a class Author and a class Book. A book does have an author so a book class contains a author object, right?
Following SRP I may not declare an author object in the book clas? I find it quite strange certainly for a beginner in OOP.
But a Tennisplayer still have a Club object, right? so if I keep the members list in a private field, it's correct that I can no longer alter the list directly, but now I can alter the list by using the public methods add/remove members. This way a TennisPlayer object cann still alter a club.
I understand I have to work with properties, but I can' manage to secure the list members of the club class.
public class Club
{
public string Name;
public List<TennisPlayer> Members { get; }
public Club(string name)
{
Name = name...
Thanks for your answer. Now I know I'm on the good track.
Now assume that class Club has an extra field Name (the name of the club).
Imagine I create a Club object 'c' and a Tennisplayer object 't'. By using the constructor of the t I link t to c.
Trough t I can now reach c and acces the...
Hi erveryone,
I got a question I want to clarify by using an example.
I have a Club class and a TennisPlayer class. A club can have many tennisplayers as members to that club, and a tennisplayer can only be member at one club at a time.
My classes would look like this. I simplified the classes...
Hi!
Can someone explain me the difference between:
class Program
{
static void Main(string[] args)
{
int number = 10;
double dNumber = System.Convert.ToDouble(number);
}
}
And:
class Program
{
static void...
Hi everyone,
I started learning C# and got totaly confused by the behaviour of the is keyword.
I understand that in the example below the value for b will be true:
int number = 10;
bool b = number is int;
In underneath example the value for for b will be false:
int number = 10;
bool b =...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.