RudiVisser's Profile User Rating: -----

Reputation: 1007 Grandmaster
Group:
Mentors
Active Posts:
3,575 (1.59 per day)
Joined:
05-June 09
Profile Views:
69,180
Last Active:
User is offline Jun 26 2015 05:11 AM
Currently:
Offline

Previous Fields

Country:
GB
OS Preference:
Windows
Favorite Browser:
Opera
Favorite Processor:
Intel
Favorite Gaming Platform:
Playstation
Your Car:
Mercedes
Dream Kudos:
225
Expert In:
PHP, MySQL, HTML, CSS, C#

Latest Visitors

Icon   RudiVisser has not set their status

Posts I've Made

  1. In Topic: Domain Model and Entity Framework

    Posted 26 Jun 2015

    Alright - 2 things.

    1; Your EF Model can be simplified massively
    I'm not sure why you're using the model builder other than to conform to some tutorial, but it's simply not required. The code below has the same effect.

    I suggest you do the following things:
    • Look into what's provided by System.ComponentModel.DataAnnotations.Schema
    • Use generic interfaces for collections (ICollection<T>) in your entities (not so required)
    • Use lazy-loading on your POCOs so as to reduce the time taken to initially load from DB, further results off these navigation properties (disregarding use of Include) will be loaded when you use them


        [Table("StudentInfo")]
        public class Student
        {
            [DatabaseGenerated(DatabaseGeneratedOption.None)]
            public int StudentID { get; set; }
            public string StudentName { get; set; }
            public DateTime? DateOfBirth { get; set; }
            public decimal Height { get; set; }
            public decimal Weight { get; set; }
            public int StandardKey { get; set; }
            [ForeignKey("StandardKey")]
            public virtual Standard Standard { get; set; }
    
            public override string ToString()
            {
                return "Student Name = " + StudentName + " Standard = " + Standard.ToString();
            }
        }
    
        [Table("StandardInfo")]
        public class Standard
        {
            [DatabaseGenerated(DatabaseGeneratedOption.None)]
            public int StandardId { get; set; }
            public string StandardName { get; set; }
    
            public ICollection<Student> Students { get; set; }
    
            public override string ToString()
            {
                return StandardName;
            }
        }
    
        public class SchoolContext : DbContext
        {
            public SchoolContext()
                : base("Data Source=localhost; Initial Catalog=TestingPurposeDB; Integrated Security=true") { }
    
            public DbSet<Student> Students { get; set; }
            public DbSet<Standard> Standards { get; set; }
        }
    
    


    2; Why do you want to further separate into 3 layers?
    Don't do it just because you read somewhere that it's best.

    Entity Framework stays out of the way for the most part, which is why they are called "POCO"s (ie. Plain Old Code Objects) allowing you to use EF's Entities as standard classes in your application too.

    The only time I can foresee requiring another layer is if your data models are entirely standalone and in another assembly (For example a Project.DataModels.dll assembly) and you need to provide additional functionality above this data. Even then, I'd suggest simply inheriting from these data models so as to not create another layer per se.

    Note that partial does not mean what you think it means. Partial is not extending your methods nor creating another layer, it's simply spreading the class declaration across multiple files. I'd suggest you don't do this.

    If you're sure that you need to do what you're saying and create an additional layer, then let us know what you tried to do with your partial class.
  2. In Topic: Domain Model and Entity Framework

    Posted 26 Jun 2015

    Methods on your EF POCO will work just fine as per the "Domain Model". You can do far more complex things on your POCO that you want your application to utilise, but EF to ignore.

    The problem seems more that nothing is being returned from your call to SingleOrDefault.

    Could you please verify by debugging if result is actually your object or not?
  3. In Topic: MVC , dropdown lsit

    Posted 15 May 2014

    What is your problem, what have you tried exactly?
  4. In Topic: Looking for an experienced developer.

    Posted 23 Apr 2014

    So you're looking for somebody to design the software for your company with no payment, in return for a 10% stake in a system that they built 100%?

    Basically.
  5. In Topic: parts of an n-tier application

    Posted 23 Apr 2014

    Entity Access Layer? ie. the models for Entity Framework, just as you have models for your business and data layer.

    However, I've never seen so much benefit in separating the two, nevermind 3, from one another. Especially when it comes to using POCOs as your data models, that's sortof the point in that they're multifunctional.

    Anyway, the file names will be the same as they are probably mapping to one another as they're essentially the same thing. It's hard to say without contents of said files.

My Information

Member Title:
.. does not guess solutions
Age:
24 years old
Birthday:
November 20, 1990
Gender:
Location:
Manchester, UK
Full Name:
Rudi Visser
Years Programming:
8
Programming Languages:
C, C++, ASM, C#, PHP/MySQL, XHTML, CSS

Contact Information

E-mail:
Private
MSN:
MSN  devmsn@rudivisser.com
Website URL:
Website URL  http://www.rudiv.se/
Skype:
Skype  muppetalert
LinkedIn:
http://uk.linkedin.com/in/rudiv
Facebook:
http://www.facebook.com/puppetalert
Twitter:
rudi_visser
Xfire:
muppetalert

Comments

  • (2 Pages)
  • +
  • 1
  • 2
  1. Photo

    sexie gal Icon

    09 Mar 2012 - 11:34
    Why do we need temporarycodes
  2. Photo

    E_Geek Icon

    11 Sep 2011 - 12:50
    :O I'm waiting on my free professional design! My big bruv told me it would be done by the time I start uni, which is friday, but I have a sneaky suspicion he may have been lying, since he told me it would be done next weekend :|
  3. Photo

    calvinthedestroyer Icon

    06 Sep 2011 - 19:40
    $10 say's that's not you in your profile pic smooching some girl :P
  4. Photo

    e_i_pi Icon

    06 Sep 2011 - 00:11
    Congrats on the promo!
  5. Photo

    Dormilich Icon

    05 Sep 2011 - 04:28
    Congratulation to your promotion!
  6. Photo

    codeprada Icon

    02 Sep 2011 - 11:38
    Congratz on the promotion.It was well deserved.
  7. Photo

    Dormilich Icon

    12 Aug 2011 - 01:23
    for your session tutorial: http://www.dreamincode.net/code/snippet5498.htm
  8. Photo

    codeprada Icon

    05 Aug 2011 - 10:09
    Pretty good blog you got there ;)
  9. Photo

    EnvXOwner Icon

    22 Jul 2011 - 12:37
    No problem :)
  10. Photo

    EnvXOwner Icon

    22 Jul 2011 - 05:59
    Hey man, your site's awesome. I could suggest that you increase the line-height. In the recent news section the letters are touching each other.
  11. Photo

    gabehabe Icon

    28 Jun 2011 - 03:24
    LUV U
  12. Photo

    pwz2000 Icon

    25 Mar 2011 - 07:31
    I was looking for a coder who could finish a humor website in six months of time.
  13. Photo

    pwz2000 Icon

    25 Mar 2011 - 07:24
    I sent you a e-mail to your MSN id about freelance opportunity,
  14. Photo

    gabehabe Icon

    10 Mar 2011 - 09:28
    Ruuuuuuudiiiiiiiiii!!! <333333333
  15. Photo

    nick1200 Icon

    07 Nov 2010 - 09:40
    would you be able to code me a new pokemon rpg ? if so how much would i have to pay :)
  • (2 Pages)
  • +
  • 1
  • 2