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

On update related entities' properties are all null - using EF code first

1 Answer 47 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Johan
Top achievements
Rank 1
Johan asked on 17 Sep 2013, 09:49 AM
Hi

Using ajax my data source is configured as follow:

.Read(read => read.Action("Containers_Read", "ContainerAdmin"))
        .Create(update => update.Action("Containers_Create", "ContainerAdmin"))
        .Update(update => update.Action("Containers_Update", "ContainerAdmin"))
        .Destroy(update => update.Action("Containers_Delete", "ContainerAdmin"))
When my grid first loads all the related entities with data comes through from the repository just fine:

public ActionResult Containers_Read([DataSourceRequest] DataSourceRequest request)
        {  
            return Json(_repository.GetAllAssetTakeOnContainers().ToDataSourceResult(request));
        }
public List<AssetTakeOnContainer> GetAllAssetTakeOnContainers()
        {
            using (var context = new AssetTakeOnContext())
            {
                context.Configuration.LazyLoadingEnabled = false;
 
                return context.AssetTakeOnContainers.Include("TakeOns").Include("LocationLevel1").Include("LocationLevel2").Include("LocationLevel3").Include("CostCntrLevel1").Include("CostCntrLevel2").Include("CostCntrLevel3").Include("Contact").Include("RoomType").Where(c => c.IsDeleted == false).ToList();
            }
        }
But as soon as I do an update my related entities seems to be populated but all properties set to null:

[AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Containers_Update([DataSourceRequest] DataSourceRequest request, AssetTakeOnContainer container)
        {
            _repository.UpdateAssetTakeOnContainer(container);
 
            return Json(ModelState.ToDataSourceResult());
        }
Please see attached file for a screenshot from VS.

Can someone please tell me why this is and what I'm doing wrong here?

Thanks

1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 19 Sep 2013, 08:45 AM
Hi Ryno,

I tried to reproduce the problem locally but to no avail – everything is working as expected on our side. Could you please provide runable project where the issue is reproduced? This would help us pinpoint the exact reason for this behavior.

Also please note that our offline demos contains such example of editing of nested properties -  "Editing custom". The offline examples can be found under the installation folder of KendoUI:

  • ..\Telerik\Kendo UI for ASP.NET MVC Q2 2013\wrappers\aspnetmvc\Examples
Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Johan
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or