Closed petrkasnal closed 1 year ago
There have been some Enum related fixes since 6.0 so it may help to install the latest NuGet version of the expression mapping library.
On the other hand you could be doing something EF does not support - you're showing an SQL exception. Something explicit like this should work.
Hi,
i use your extension. But I ran into one problem. I found that if I want to use filters on enum, I have to write the following line for each propert, which I guess I don't mind.
var data = (_repository.GetAll().GetQuery(_mapper, request.Query)).ToList();
.ForMember(src => src.AType, opt => opt.MapFrom((source, dest, value, context) => context.Mapper.Map<AType>(source.AType)))
But the bigger problem is that when I have enums stored as strings in the database, GetQuery doesn't work even if I have more than one line for that property. Filter isn't working but select isn't working too. What should I do about it? I get this error:
Message: Conversion failed when converting the nvarchar value 'Error' to data type int.
Stack at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Actiond__3.MoveNext()
1 wrapCloseInAction) at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action
1 wrapCloseInAction) at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at Microsoft.Data.SqlClient.SqlDataReader.TryHasMoreRows(Boolean& moreRows) at Microsoft.Data.SqlClient.SqlDataReader.TryReadInternal(Boolean setTimeout, Boolean& more) at Microsoft.Data.SqlClient.SqlDataReader.Read() at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.Enumerator.MoveNext() at System.Collections.Generic.List
1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable
1 source) at Aimtec.DEEPAPP.DataIntegrator.Application.Handlers.Boms.Queries.All.AllBomQueryHandler.Handle(AllBomQuery request, CancellationToken cancellationToken) in C:\user\workspace\Aimtec.DEEPAPP.DataIntegrator.WebApi\Src\Aimtec.DEEPAPP.DataIntegrator.Application\Handlers\Boms\Queries\All\AllBomQuery.cs:line 55 at MediatR.Wrappers.RequestHandlerWrapperImpl2.<>c__DisplayClass1_0.<Handle>g__Handler|0() at Aimtec.Framework.Mediator.Behaviors.AimtecAuthorizationBehaviour
2.Thank you very much