graphdiff

Conditional mapping with graphdiff

一笑奈何 提交于 2019-12-22 01:23:51
问题 I have following entities in my DbContext : public class A { public A() { Bs = new List<B>(); } public ICollection<B> Bs { set; get; } } Sometimes I Want to update a graph: var a = dbContext.As .AsNoTracking() .Include(x=>x.Bs) .firstOrDefault(); var c = new C(); a.Bs.Add(c); var d = new D(); var e1 = new E(); var e2 = new E(); d.Es.Add(e1); //<-- added new E d.Es.Add(e2); //<-- added new E a.Bs.Add(d); I want to update a with its Bs (update C , D , E too) using graphdiff : dbContext

The relationship could not be changed because one or more of the foreign-key properties is non nullable

倾然丶 夕夏残阳落幕 提交于 2019-12-17 15:42:51
问题 I get following error during update with EF: The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted. Is there any general way to find

The relationship could not be changed because one or more of the foreign-key properties is non nullable

拜拜、爱过 提交于 2019-12-17 15:42:29
问题 I get following error during update with EF: The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted. Is there any general way to find

Update Many-to-Many Association with GraphDiff

瘦欲@ 提交于 2019-12-10 10:06:04
问题 I have the following data model: My business logic works with detached entities so I'm using GraphDiff to perform updates. I'm having trouble updating the PerfModes/CalcPoints association. Conceptually, Block owns CalcPoints and PerfModes, but CalcPoints can be associated with any number of PerfModes. I'm trying to do updates at the Block level. The code I came up with doesn't throw any errors (while other attempts did) but neither does it update the PerfModes/CalcPoints association.

Conditional mapping with graphdiff

别等时光非礼了梦想. 提交于 2019-12-04 22:13:59
I have following entities in my DbContext : public class A { public A() { Bs = new List<B>(); } public ICollection<B> Bs { set; get; } } Sometimes I Want to update a graph: var a = dbContext.As .AsNoTracking() .Include(x=>x.Bs) .firstOrDefault(); var c = new C(); a.Bs.Add(c); var d = new D(); var e1 = new E(); var e2 = new E(); d.Es.Add(e1); //<-- added new E d.Es.Add(e2); //<-- added new E a.Bs.Add(d); I want to update a with its Bs (update C , D , E too) using graphdiff : dbContext.UpdateGraph(a,map=>map.OwnedCollection(x=>x.Bs)); This updates A , B s, C s, D s, but not E s. So I think, I

Exception in Expression Trees

不羁岁月 提交于 2019-11-29 11:44:06
This is my model: - Business - BusinesType - FK - Categories (*) - FK - Branch (*) - BranchType - FK - Address - Phone (*) - CustomFields (*) - OpeningTimes (*) - WorkingPeriods (*) - ..... Now I have a controller-action that accepts a form that consists of the whole bunch of data as a single Business entity with all its properties and collections set fine. Now I have to walk thru all the properties and collections recursively, and compare with the database graph; if they don't exist, add them, if they do walk thru all properties again and perform the same to a deeper level until no navigation

Exception in Expression Trees

落爺英雄遲暮 提交于 2019-11-28 05:03:55
问题 This is my model: - Business - BusinesType - FK - Categories (*) - FK - Branch (*) - BranchType - FK - Address - Phone (*) - CustomFields (*) - OpeningTimes (*) - WorkingPeriods (*) - ..... Now I have a controller-action that accepts a form that consists of the whole bunch of data as a single Business entity with all its properties and collections set fine. Now I have to walk thru all the properties and collections recursively, and compare with the database graph; if they don't exist, add

The relationship could not be changed because one or more of the foreign-key properties is non nullable

烂漫一生 提交于 2019-11-27 19:20:48
I get following error during update with EF: The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted. Is there any general way to find which foreign-key properties cause above error? [Update] For one case following code cause above error(I