SampleDataContext db = new SampleDataContext(); // use the primary key Task task = db.Manager.Task.GetByKey(taskId); // use a foreign key var myTasks = db.Manager.Task.GetByAssignedID(userId); // the methods return IQueryable so you can add expressions var openTasks = db.Manager.Task.GetByStatusID(statusId).OrderBy(t => t.CreateDate);
private class Metadata { // Only Attributes in the class will be preserved. public int OrderId { get; set; } [Required] [StringLength(20)] public string UserId { get; set; } [Range (typeof(DateTime), "10-31-2008", "12-25-2200")] public System.DateTime OrderDate { get; set; } ....... }
static partial void AddRules() { // Rule allows the Name property to be a max of 150 characters. RuleManager.AddShared<Task>(new LengthRule("Name", 150)); // Rule that validates the value of the property using regex. RuleManager.AddShared<Task>(new RegexRule("Name", ".*")); // Rule allows only users in certain security roles to update. RuleManager.AddShared<Task>(new UpdateRule(new string[] { "Administrator", "Updaters" })); }