can't convert nullable to non nullable using expression mapping
here is the code :
Model { public Guid Id { get; set; } }
Dto {public Guid? Id { get; set; } }
Service layer {
public async Task GetFirstOrDefaultAsync(Expression<Func<TDto, bool>> dtoPredicate)
{
var predicate = Mapper.MapExpression<Expression<Func<T, bool>>>(dtoPredicate);
var result = await Repository.FirstOrDefaultAsync(predicate);
var dtoResult = Mapper.Map(result);
return dtoResult ;
}
}
expection : Message =The source and destination types must be the same for expression mapping between literal types. Source Type: Guid, Source Description: Id, Destination Type: Nullable`1, Destination Property: Id.
can't convert nullable to non nullable using expression mapping here is the code : Model { public Guid Id { get; set; } } Dto {public Guid? Id { get; set; } }
Service layer { public async Task GetFirstOrDefaultAsync(Expression<Func<TDto, bool>> dtoPredicate)
{
var predicate = Mapper.MapExpression<Expression<Func<T, bool>>>(dtoPredicate);
var result = await Repository.FirstOrDefaultAsync(predicate);
var dtoResult = Mapper.Map(result);
return dtoResult ;
}
}
expection : Message =The source and destination types must be the same for expression mapping between literal types. Source Type: Guid, Source Description: Id, Destination Type: Nullable`1, Destination Property: Id.