Skip to content

Bug: Batch Update with Inheritance #238

Open
@novamxd

Description

@novamxd

Hello,

I have a base modal class "SystemObject" which has a bunch of common properties of all my models (like Created Date, OwnerId, etc) stored in a table SystemObject. All my other models store their data in their separate tables.

Z.EntityFramework.Plus.EF6 Version: 1.6.21

Example:

[Table("SystemObject")]
public class SystemObject
{
	public Guid Id {get; set;}
	
	public DateTime Created {get;set;}
	
	public bool Deleted {get;set;}
}

[Table("User")]
public class User : SystemObject
{
	public string Username {get;set;}
}

If I try to update a SystemObject column when using the Update() extension on the child class User, it fails with an exception: The destination column could not be found:{column}. The offending line in the code is 911 of shared\Z.EF.Plus.BatchUpdate.Shared\BatchUpdate.cs.

Example:

using(MainContext mcContext = new MainContext())
{
	//mark "TestUser" as deleted
	mcContext
		.Users
			.Where(i => i.Username == "TestUser")
			.Update(i => new User() 
			{ 
				Deleted = true 
			});
}

Without digging into it, it sounds like the ScalarProperties collection doesn't include inherited properties, so either that needs to include them or it needs to look through base classes. Can I get a fix for this?

Thanks!

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions