Linked Questions

0 votes
2 answers
2k views

I have seen people use the virtual keyword for property like this: public class Client { public virtual int? Id { get; set; } public virtual string Name { get; set; } public virtual ...
Mou's user avatar
  • 16.4k
0 votes
3 answers
236 views

What is the purpose of virtual in C#? What is the proper way and reason to use it? For example, public virtual ICollection<Order> Orders { get; set; } in defining a collection orders in a ...
muttley91's user avatar
  • 12.8k
254 votes
2 answers
107k views

Does the virtual keyword has an effect when used on the properties in EF Code First?. Can someone describe all of its ramifications in different situations? For instance, I know it can control lazy ...
Scott Stafford's user avatar
58 votes
1 answer
28k views

I have following POCO class being used in EF 6.x. My question: Why is the navigation property of 'Posts' under 'Blog' entity declared as virtual? public class Blog { public int BlogId { get; ...
Sunil's user avatar
  • 21.6k
7 votes
3 answers
18k views

I got 3 entities(tables) that have many to many connections: public class AccUserRole { public long Id { get; set; } public string RoleName { get; set; } public List<AccAdGroup> ...
Evgeni Dimitrov's user avatar
3 votes
2 answers
2k views

I am pretty new to C#. I have two classes a Movie class and a Genre class.I cant understand the property "public virtual Genre Genre" Could someone explain me this? Following are the two classes ...
hEShaN's user avatar
  • 591
2 votes
1 answer
6k views

I'm following a tutorial series about MVC4 on PluralSight and the presenter sets all of the properties of all of his models as virtual. I haven't seen others do this and I was wondering if it is the ...
Doug S.'s user avatar
  • 682
0 votes
1 answer
3k views

public class Student { public int StudentId; public string StudentName; public int CourseId; public virtual Course Courses { get; set; } } public class Course { public int ...
ltog's user avatar
  • 1
4 votes
1 answer
997 views

I have added 3 new fields to my Register.aspx template (FirstName, LastName, BuisnessName). I have updated the database schema but when I register a new user, the user is created but the new fields ...
joseph Laurello's user avatar
1 vote
1 answer
2k views

EDIT: This question has been closed because someone thought it is a duplicate for another question on SO. It is not. The duplicate question, and all of the (old) docs I've found, deal with adding ...
Bob.at.Indigo.Health's user avatar
0 votes
1 answer
1k views

I have a problem with EF. May I misunderstand something.... So i have a simple model: public class Image { [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } ...
Student's user avatar
2 votes
1 answer
618 views

I want to know when we use the key word virtual with navigation properties (I learnt it's for lazy loading) but I'm reading a tutorial in https://docs.asp.net/en/latest/data/ef-mvc/intro.html that ...
Jacinthe2011's user avatar
0 votes
1 answer
588 views

I have two models which are related like following: public class Context { [Key] public long ContextId { get; set; } [Required] public string Role { get; set; } ...
Thinker's user avatar
  • 5,396
0 votes
1 answer
237 views

Consider this model. Basically what I'm trying to do is obtaining every door in the table 'doors' such that there exists a corresponding entry in the table 'doors_to_devices' with a given device_id. ...
CuriousCharlie's user avatar
0 votes
2 answers
170 views

I have a DBContext that is initializing through DropCreateDatabaseAlways class. In the Seed method I have this code: base.Seed(context); var c1 = new Company { Name = "Samsung"...
Victor Gorban's user avatar

15 30 50 per page