yevhen / Streamstone

Event store for Azure Table Storage

Home Page:http://streamstone.net/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Question/Possible bug] Is it intended not to support Nullable<DateTime> in PropertyMap?

chyczewski-maciej opened this issue · comments

Sorry if I'm asking a dumb question here. I have no broad picture of the project's implementation.

I found an anomaly in this method. All struct types are supported together with their Nullable representations. The only exception is DateTime - DateTime? is not supported.
Is it intended?

Code currently exists here:

static EntityProperty ToEntityProperty(string key, object value, Type type)
{
if (type == typeof(byte[]))
return new EntityProperty((byte[])value);
if (type == typeof(bool) || type == typeof(bool?))
return new EntityProperty((bool?)value);
if (type == typeof(DateTimeOffset) || type == typeof(DateTimeOffset?))
return new EntityProperty((DateTimeOffset?)value);
if (type == typeof(DateTime))
return new EntityProperty((DateTime?)value);
if (type == typeof(double) || type == typeof(double?))
return new EntityProperty((double?)value);
if (type == typeof(Guid) || type == typeof(Guid?))
return new EntityProperty((Guid?)value);
if (type == typeof(int) || type == typeof(int?))
return new EntityProperty((int?)value);
if (type == typeof(long) || type == typeof(long?))
return new EntityProperty((long?)value);
if (type == typeof(string))
return new EntityProperty((string)value);
throw new NotSupportedException("Not supported entity property type '" + value.GetType() + "' for '" + key + "'");
}

Code was originally introduced here:

static EntityProperty ToEntityProperty(string key, object value, Type type)
{
if (type == typeof(byte[]))
return new EntityProperty((byte[])value);
if (type == typeof(bool) || type == typeof(bool?))
return new EntityProperty((bool?)value);
if (type == typeof(DateTimeOffset) || type == typeof(DateTimeOffset?))
return new EntityProperty((DateTimeOffset?)value);
if (type == typeof(DateTime))
return new EntityProperty((DateTime?)value);
if (type == typeof(double) || type == typeof(double?))
return new EntityProperty((double?)value);
if (type == typeof(Guid) || type == typeof(Guid?))
return new EntityProperty((Guid?)value);
if (type == typeof(int) || type == typeof(int?))
return new EntityProperty((int?)value);
if (type == typeof(long) || type == typeof(long?))
return new EntityProperty((long?)value);
if (type == typeof(string))
return new EntityProperty((string)value);
throw new NotSupportedException("Not supported entity property type '" + value.GetType() + "' for '" + key + "'");
}

Looks like a bug. Don't think there any reason why it was omitted.

Done!