I'm using a custom KonstruktRepository, but the protected override T SaveImpl(T entity) doesn't seem to be working. When I save an entity the custom SaveImpl() method is never hit and I get the following error:
Sequence contains more than one matching element
at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException()
at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)
at Konstrukt.Web.WebApi.Validation.KonstruktEntityValidator.ValidatePropertyData(ModelStateDictionary modelState, KonstruktEntityPostModel postModel, KonstruktEditorFieldConfig[] configProps, Object entity, KonstruktEditorMode editorMode)
at Konstrukt.Web.WebApi.Validation.KonstruktEntityValidator.Validate(KonstruktCollectionConfig collectionConfig, ModelStateDictionary modelState, KonstruktEntityPostModel postModel, Object entity, KonstruktEditorMode editorMode)
at Konstrukt.Web.Controllers.Api.KonstruktApiController.SaveEntity(KonstruktEntityPostModel postModel)
at lambda_method201(Closure , Object , Object[] )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
So it's failing property validation before it event gets to your entity save routine.
Looking at the code for ValidatePropertyData it would appear it fails when it tries to lookup a configured property in your post model. The ThrowMoreThanOneMatchException would suggest you somehow have more than one property that matches a specific alias.
I'd check your config / models for duplicate properties.
I wanted to an "Info label" data type to the top of the editor view which shows some basic instructions. I had to bind it to an entity field in the AddField() method, so I used the Name field, but this field was also being used in another editor field. I've now added a dummy/placeholder field to the entity model that I can use to display the info label:
SaveImpl() on custom repository doesn't work
I'm using a custom
KonstruktRepository
, but theprotected override T SaveImpl(T entity)
doesn't seem to be working. When I save an entity the customSaveImpl()
method is never hit and I get the following error:Sequence contains more than one matching element
Or am I missing something?
So it's failing property validation before it event gets to your entity save routine.
Looking at the code for
ValidatePropertyData
it would appear it fails when it tries to lookup a configured property in your post model. TheThrowMoreThanOneMatchException
would suggest you somehow have more than one property that matches a specific alias.I'd check your config / models for duplicate properties.
I wanted to an "Info label" data type to the top of the editor view which shows some basic instructions. I had to bind it to an entity field in the
AddField()
method, so I used the Name field, but this field was also being used in another editor field. I've now added a dummy/placeholder field to the entity model that I can use to display the info label:And now the
SaveImpl()
method works as expected.is working on a reply...