This is a migrated thread and some comments may be shown as answers.

I need to extend my model with a one-to-many realtion, how do I do that?

3 Answers 21 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jonas
Top achievements
Rank 1
Jonas asked on 03 Sep 2015, 08:13 AM

Hello

I have a grid displaying workitems and the last action taken for a workitem, recently I discovered that I need to extend this to include a history of actions stored in a separate table in the db.

the two tables looks like this:

workItem
id
name
lastActionDate
lastActionText

workAction
id
workItemID
actionDate
ActionText

My model currently looks like this:

public class workItemModel
    {
        public int id { get; set; }
        public string name{ get; set; }
        public DateTime lastActionDate{ get; set; }
        public string lastActionText{ get; set; }
    }

and my read action for the grid looks like this:

public ActionResult workItems_Read([DataSourceRequest]DataSourceRequest request)
        {
            return Json(GetWorkItems().ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
        }
 
        private static IEnumerable<workItemModel> GetWorkItems()
        {
            var wimDB = new wimDB_DEVEntities();
            return wimDB.workItem.Select(wiModel => new workItemModel
            {
                id = wiModel.id,
                name = wiModel.name,
                lastActionDate = wiModel.lastActionDate,
                lastActionText= wiModel.lastActionText
            });
        }
 

How do I extent my model and my read action to include the workAction table from the db?

/Jonas

3 Answers, 1 is accepted

Sort by
0
Jonas
Top achievements
Rank 1
answered on 04 Sep 2015, 11:32 AM

Hello

No one got an answer for this?

/Jonas

0
Accepted
Viktor Tachev
Telerik team
answered on 04 Sep 2015, 02:36 PM
Hi Jonas,

Please check out the following article that describes how you can configure more complex Model.




Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Jonas
Top achievements
Rank 1
answered on 08 Sep 2015, 08:06 AM
Thank you!
Tags
Grid
Asked by
Jonas
Top achievements
Rank 1
Answers by
Jonas
Top achievements
Rank 1
Viktor Tachev
Telerik team
Share this question
or