Replies: 2 comments 1 reply
-
Hi @moxplod, public IEnumerable<IGMap<T>> GetCurrentMapsByType(HashSet<Type> targetTypes)
{
foreach (var map in _mappings)
{
if (map.To.Body is UnaryExpression unaryExpression) // this is needed for unboxing dateTimes
{
if (targetTypes.Contains(unaryExpression.Operand.Type))
{
yield return map;
}
}
// TODO: need to implement other types that aren't unary expression
}
} usage: [Fact]
public void GetMappingByType()
{
var gm = new GridifyMapper<TestClass>(true);
var dates = gm.GetCurrentMapsByType([typeof(DateTime), typeof(DateTime?)]);
Assert.Single(dates);
} if we want to add this method to GridifyMapper we should also add another generic overload for this method. ( |
Beta Was this translation helpful? Give feedback.
1 reply
-
Added PR - #214 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi @alirezanet following up on #211
I want to add a custom value converter in my code for EACH datetime property in the mappings.
I have 2 thoughts here:
How can I iterate over each of these IGMaps and determine if they are a DateTime property or not? Should we add FromType in IGMap so that this can be inferred easily?
Or is it a better approach to create a Global configuration similar to CustomOperators and create CustomValueConvertors - then provide a Type and the convertor method. Something like a Dictionary<Type, Func<string, object>>
Beta Was this translation helpful? Give feedback.
All reactions