How do I handle List of MyClass in Entity Framework
I tired many things many times and couldn’t figure out what works and ended up X to Y problems.
ExecuteSql to create table in EF Core
I have a method to create tables at runtime:
Entity framework execute update lambda argument to ‘SetProperty’ does not represent a valid property to be set
if (typeof(T).GetInterface(nameof(IHasEntityModifierData)) != null) { await _context.Set<T>() .Where(predicate) .ExecuteUpdateAsync(a=>a.SetProperty(p=>(p as IHasEntityModifierData).LastModifiedDate,DateTime.UtcNow)); } Error is: ExecuteUpdate(a => a.SetProperty<DateTime?>(rn propertyExpression: p => (p as IHasEntityModifierData).LastModifiedDate, rn valueExpression: (DateTime?)DateTime.UtcNow))’ could not be translated. Additional information: The following lambda argument to ‘SetProperty’ does not represent a valid property to be set: ‘p => (p as IHasEntityModifierData).LastModifiedDate’ Suppose I have […]
How to unit test FromSqlInterpolated in EFCore?
I want to write a unit test for a method that returns data from a stored procedure, how do I mock this?