Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit d99a054

Browse files
committed
Allow Value types (like Guid) do not throw an exception on Scalar operations
1 parent 7db6c40 commit d99a054

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/ServiceStack.OrmLite/OrmLiteSPStatement.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public List<T> ConvertToList<T>()
5454

5555
public List<T> ConvertToScalarList<T>()
5656
{
57-
if (!((typeof(T).IsPrimitive) || (typeof(T) == typeof(string)) || (typeof(T) == typeof(String))))
57+
if (!((typeof(T).IsPrimitive) || typeof(T).IsValueType || (typeof(T) == typeof(string)) || (typeof(T) == typeof(String))))
5858
throw new Exception("Type " + typeof(T).Name + " is a non primitive type. Use ConvertToList function.");
5959

6060
IDataReader reader = null;
@@ -90,7 +90,7 @@ public T ConvertTo<T>()
9090

9191
public T ConvertToScalar<T>()
9292
{
93-
if (!((typeof(T).IsPrimitive) || (typeof(T) == typeof(string)) || (typeof(T) == typeof(String))))
93+
if (!((typeof(T).IsPrimitive) || typeof(T).IsValueType || (typeof(T) == typeof(string)) || (typeof(T) == typeof(String))))
9494
throw new Exception("Type " + typeof(T).Name + " is a non primitive type. Use ConvertTo function.");
9595

9696
IDataReader reader = null;
@@ -108,7 +108,7 @@ public T ConvertToScalar<T>()
108108

109109
public List<T> ConvertFirstColumnToList<T>()
110110
{
111-
if (!((typeof(T).IsPrimitive) || (typeof(T) == typeof(string)) || (typeof(T) == typeof(String))))
111+
if (!((typeof(T).IsPrimitive) || typeof(T).IsValueType || (typeof(T) == typeof(string)) || (typeof(T) == typeof(String))))
112112
throw new Exception("Type " + typeof(T).Name + " is a non primitive type. Only primitive type can be used.");
113113

114114
IDataReader reader = null;
@@ -126,7 +126,7 @@ public List<T> ConvertFirstColumnToList<T>()
126126

127127
public HashSet<T> ConvertFirstColumnToListDistinct<T>()
128128
{
129-
if (!((typeof(T).IsPrimitive) || (typeof(T) == typeof(string)) || (typeof(T) == typeof(String))))
129+
if (!((typeof(T).IsPrimitive) || typeof(T).IsValueType || (typeof(T) == typeof(string)) || (typeof(T) == typeof(String))))
130130
throw new Exception("Type " + typeof(T).Name + " is a non primitive type. Only primitive type can be used.");
131131

132132
IDataReader reader = null;

0 commit comments

Comments
 (0)