win7user10 / Laraue.EfCoreTriggers

Library to write triggers in C# with EF.Core
MIT License
112 stars 20 forks source link

Support for EF.Property (shadow properties) #65

Open Xriuk opened 1 year ago

Xriuk commented 1 year ago

At the moment EF.Property is not supported. I tried adding it as an IMethodCallVisitor but it gives me an error:

Expression of type System.Linq.Expressions.TypedParameterExpression is not supported

I guess it's because of the first argument which is the instance of the entity.

I'm using it as argumentSelectors parameter in ExecuteRawSql with something like that:

modelBuilder.Entity<Brand>().InsteadOfDelete(a => a.Action(a => a.ExecuteRawSql("... = {0}", b => EF.Property<int>(b, "MyId"))));

but it think it should be the same in other expressions.

I would need this feature to allow triggers to target a shadow property (which is mapped to a column) of the entity, my question is: how can I replace this condition correctly? So that it gets added to the list of columns which get fetched into the cursor, and generates the correct SQL. I don't think IMethodCallVisitor is the most appropriate method at this point.

From a quick look at the code (specially the TriggerVisitor) I see that for each visited member should be declared on the entity, right?

max-kuzmin commented 4 months ago

I stuck with this problem too