Skip to content

Instantly share code, notes, and snippets.

@dnasca
Last active August 29, 2015 14:18
Show Gist options
  • Select an option

  • Save dnasca/7b768ebf3ebe179de92c to your computer and use it in GitHub Desktop.

Select an option

Save dnasca/7b768ebf3ebe179de92c to your computer and use it in GitHub Desktop.
Creating a Data layer - 1a.) Data Model Classes - Starting at the top level of our 'Note'
/*
Let's start by creating the top level model.
1. Every Note has a Topic and a body.
2. Every Topic can have a Reply.
This class will represent one instance of that topic. The next class will model the Reply.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Note.Data
{
public class Topic
{
public int Id { get; set; } //Entity is smart enough to know what to do with the property of type int with the name Id,
//and will follow our configuration (Guid, auto-increment)
public string Title { get; set; }
public string Body { get; set; }
public DateTime Created { get; set; }
public ICollection<Reply> Replies { get; set; } // ICollection will carry Replies, the type Reply will be the next class we make. The interface knows how to enumerate, remove, add items to itself.
// The dB will handle storing this as a correct collection
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment