Created
May 28, 2013 22:40
-
-
Save bhameyie/5666703 to your computer and use it in GitHub Desktop.
simple.data example 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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