private EntityProperty GetEntityPropertyForType(string type, string value)
{
if (type == "datetime")
{
DateTime? typedValue = string.IsNullOrWhiteSpace(value) ? null : new DateTime?(DateTime.Parse(value));
return new EntityProperty(typedValue);
}
if (type == "datetimeoffset")
{
DateTimeOffset? typedValue = string.IsNullOrWhiteSpace(value)
? null
: new DateTimeOffset?(DateTimeOffset.Parse(value));
return new EntityProperty(typedValue);
}
if (type == "guid")
{
Guid? typedValue = string.IsNullOrWhiteSpace(value) ? null : new Guid?(Guid.Parse(value));
return new EntityProperty(typedValue);
}
if (type == "int")
{
int? typedValue = string.IsNullOrWhiteSpace(value) ? null : new int?(int.Parse(value));
return new EntityProperty(typedValue);
}
if (type == "double")
{
double? typedValue = string.IsNullOrWhiteSpace(value) ? null : new double?(double.Parse(value));
return new EntityProperty(typedValue);
}
if (type == "long")
{
long? typedValue = string.IsNullOrWhiteSpace(value) ? null : new long?(long.Parse(value));
return new EntityProperty(typedValue);
}
if (type == "bool")
{
bool? typedValue = string.IsNullOrWhiteSpace(value) ? null : new bool?(bool.Parse(value));
return new EntityProperty(typedValue);
}
if (type == "string")
{
return new EntityProperty(value);
}
throw new InvalidOperationException($"Type {type} not understood");
}