No factory for Optional<Guid?> -> Guid
See original GitHub issueHi
I am trying to map HotChocolate input types to entities and get this error, and could not find anything in the wiki on how to do this.
Here are example classes for DTO and Entity
public partial class CreateProjectDto
{
public Optional<Guid?> Id { get; set; }
public string Name { get; set; }
}
public class Project
{
public Guid Id { get; set; }
public string Name { get; set; };
}
Running the following code generates an exception
var project = await dbContext.MapAsync<Project>(dto);
Exception
Detached.Mappers.Exceptions.MapperException: No factory for Optional<Guid?> -> Guid
at Detached.Mappers.Mapper.<>c__DisplayClass9_0.<GetTypeMapper>b__0(TypePairKey key)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Detached.Mappers.Mapper.GetTypeMapper(TypePair typePair)
at Detached.Mappers.TypeMappers.ExpressionBuilder.BuildGetKeyExpressions(TypePair typePair, LambdaExpression& getSourceKeyExpr, LambdaExpression& getTargetKeyExpr, Type& keyType)
at Detached.Mappers.TypeMappers.Entity.Complex.EntityTypeMapperFactory.Create(Mapper mapper, TypePair typePair)
at Detached.Mappers.Mapper.<>c__DisplayClass9_0.<GetTypeMapper>b__0(TypePairKey key)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Detached.Mappers.Mapper.GetTypeMapper(TypePair typePair)
at Detached.Mappers.Mapper.Map(Object source, Type sourceClrType, Object target, Type targetClrType, IMapContext context)
at Detached.Mappers.EntityFramework.EFMapper.Map[TEntity](DbContext dbContext, Object entityOrDTO, MapParameters parameters)
at Detached.Mappers.EntityFramework.EFMapper.<>c__DisplayClass8_0`1.<MapAsync>b__0()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object obj)
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at Gateway.API.Mutations.ProjectMutations.CreateProjects(GatewayDbContext gatewayDbContext, CreateProjectDto[] dtos, CancellationToken cancellationToken) in C:\dev\Connected\src\Gateway\Gateway.API\Mutations\ProjectMutations.cs:line 21
Issue Analytics
- State:
- Created 6 months ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
How can I default a parameter to Guid.Empty in C#? - ...
Solution. You can use new Guid() instead. public void Problem(Guid optional = new Guid()) { // when called without parameters this will be ......
Read more >How do I bind list of guids on the query string in C# web api?
The right way for webapi is using the query parameter multiple times,no matter the type. i.e: endpoint?listIds=1234-5678&listIds=5555-4444.
Read more >Guid params in KeyVaultAccessControlClient should probably ...
Successfully merging a pull request may close this issue. Change optional Guid name to Guid? heaths/azure-sdk-for-net.
Read more >ACX_CIRCUIT_TEMPLATE_CO...
An optional GUID that specifies the ID of the circuit container. FactoryProperties. An ACXOBJECTBAG with the factory properties for the ...
Read more >AcxFactoryCircuitInitAssignAcxR...
This is an opaque structure that is used to store ACX Circuit factory initialization information and associate the factory with a WDF device....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@furier Hi, thanks for the interest in the library, and good for trying to write the mappers! Adding support for hot chocolate makes sense. Unfortunately I’m sick now, but I can try something next weekend If I feel better And yes, the wiki needs more work it’s not 100 % completed
credits
https://github.com/leonardoporro/Detached-Mapper/wiki/Partial-Updates