This commit is contained in:
@@ -52,9 +52,6 @@
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
@@ -5465,7 +5465,7 @@ namespace DynamORM
|
||||
|
||||
mainResult = cache.EnumerateReader().ToList();
|
||||
}
|
||||
else if (argType.IsValueType)
|
||||
else if (argType.IsValueType || types[0] == typeof(string))
|
||||
{
|
||||
Type listType = typeof(List<>).MakeGenericType(new Type[] { argType });
|
||||
IList listInstance = (IList)Activator.CreateInstance(listType);
|
||||
@@ -5481,6 +5481,25 @@ namespace DynamORM
|
||||
|
||||
mainResult = listInstance;
|
||||
}
|
||||
else if (types[0] == typeof(Guid))
|
||||
{
|
||||
Type listType = typeof(List<>).MakeGenericType(new Type[] { argType });
|
||||
IList listInstance = (IList)Activator.CreateInstance(listType);
|
||||
|
||||
object defVal = listType.GetDefaultValue();
|
||||
|
||||
IDataReader cache = null;
|
||||
using (IDataReader rdr = cmd.ExecuteReader())
|
||||
cache = rdr.CachedReader();
|
||||
|
||||
while (cache.Read())
|
||||
{
|
||||
if (cache[0] == DBNull.Value && Guid.TryParse(cache[0].ToString(), out Guid g))
|
||||
listInstance.Add(g);
|
||||
}
|
||||
|
||||
mainResult = listInstance;
|
||||
}
|
||||
else
|
||||
{
|
||||
DynamicTypeMap mapper = DynamicMapperCache.GetMapper(argType);
|
||||
@@ -5494,12 +5513,18 @@ namespace DynamORM
|
||||
mainResult = cache.EnumerateReader().MapEnumerable(argType).ToList();
|
||||
}
|
||||
}
|
||||
else if (types[0].IsValueType)
|
||||
else if (types[0].IsValueType || types[0] == typeof(string))
|
||||
{
|
||||
mainResult = cmd.ExecuteScalar();
|
||||
if (mainResult != DBNull.Value)
|
||||
mainResult = types[0].CastObject(mainResult);
|
||||
}
|
||||
else if (types[0] == typeof(Guid))
|
||||
{
|
||||
mainResult = cmd.ExecuteScalar();
|
||||
if (mainResult != DBNull.Value && Guid.TryParse(mainResult.ToString(), out Guid g))
|
||||
mainResult = g;
|
||||
}
|
||||
else
|
||||
{
|
||||
DynamicTypeMap mapper = DynamicMapperCache.GetMapper(types[0]);
|
||||
|
||||
Reference in New Issue
Block a user