Skip to content

Instantly share code, notes, and snippets.

@bhameyie
Created May 28, 2013 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhameyie/5666703 to your computer and use it in GitHub Desktop.
Save bhameyie/5666703 to your computer and use it in GitHub Desktop.
simple.data example 1
public class Story
{
public long Id { get; set; }
public string Description { get; set; }
public string Title { get; set; }
public StoryStatus Status { get; set; }
public long CreatedBy { get; set; }
public DateTime CreatedOn { get; set; }
public DateTime LastEditedOn { get; set; }
public long ProjectId { get; set; }
public Project Project { get; set; }
public List<Task> Tasks { get; set; }
public int? Estimate { get; set; }
public StoryType StoryType { get; set; }
public IterationType IterationType { get; set; }
public string Tag { get; set; }
public DateTime? AcceptedOn { get; set; }
public DateTime? TransitionedOn { get; set; }
}
//Simple.Data figures out relationship based on the table's referrential integrity
//Getting all the Stories and hydrating the Project and Task sub object
public List<dynamic> FindAll()
{
var database = Database.OpenConnection(m_connectionString);
return database.Stories.All()
.With(database.Stories.Projects.As("Project"))
.WithTasks(database.Stories.Id == database.Tasks.StoryId)
.ToList();
}
//lazy loading
public List<dynamic> FindAll()
{
var database = Database.OpenConnection(m_connectionString);
return database.Stories.All().ToList();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment