Skip to content

Commit f7bd3d7

Browse files
committed
Add support for Inserting struct and get updated values back
1 parent bab4be6 commit f7bd3d7

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

Runtime/SQLiteExtensions.cs

+35
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,39 @@ static SQLite3()
8181
#endif
8282
}
8383
}
84+
85+
public static class ISQLiteConnectionExtensions
86+
{
87+
public static int Insert<T>(this ISQLiteConnection connection, ref T obj)
88+
{
89+
object boxed = obj;
90+
int result = connection.Insert(boxed);
91+
obj = (T) boxed;
92+
return result;
93+
}
94+
95+
public static int Insert<T>(this ISQLiteConnection connection, ref T obj, Type objType)
96+
{
97+
object boxed = obj;
98+
int result = connection.Insert(boxed, objType);
99+
obj = (T) boxed;
100+
return result;
101+
}
102+
103+
public static int Insert<T>(this ISQLiteConnection connection, ref T obj, string extra)
104+
{
105+
object boxed = obj;
106+
int result = connection.Insert(boxed, extra);
107+
obj = (T) boxed;
108+
return result;
109+
}
110+
111+
public static int Insert<T>(this ISQLiteConnection connection, ref T obj, string extra, Type objType)
112+
{
113+
object boxed = obj;
114+
int result = connection.Insert(boxed, extra, objType);
115+
obj = (T) boxed;
116+
return result;
117+
}
118+
}
84119
}

0 commit comments

Comments
 (0)