Commit 67d0ac67 authored by mgravell's avatar mgravell

remove System.Data.Linq ref

parent f333c2f0
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Data.Linq" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\Dapper\Properties\AssemblyInfo.cs"> <Compile Include="..\Dapper\Properties\AssemblyInfo.cs">
......
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Data.Linq" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="SqlMapper.cs" /> <Compile Include="SqlMapper.cs" />
......
...@@ -294,9 +294,9 @@ static SqlMapper() ...@@ -294,9 +294,9 @@ static SqlMapper()
typeMap[typeof(Guid?)] = DbType.Guid; typeMap[typeof(Guid?)] = DbType.Guid;
typeMap[typeof(DateTime?)] = DbType.DateTime; typeMap[typeof(DateTime?)] = DbType.DateTime;
typeMap[typeof(DateTimeOffset?)] = DbType.DateTimeOffset; typeMap[typeof(DateTimeOffset?)] = DbType.DateTimeOffset;
typeMap[typeof(System.Data.Linq.Binary)] = DbType.Binary;
} }
private const string LinqBinary = "System.Data.Linq.Binary";
private static DbType LookupDbType(Type type, string name) private static DbType LookupDbType(Type type, string name)
{ {
DbType dbType; DbType dbType;
...@@ -310,6 +310,10 @@ private static DbType LookupDbType(Type type, string name) ...@@ -310,6 +310,10 @@ private static DbType LookupDbType(Type type, string name)
{ {
return dbType; return dbType;
} }
if (type.FullName == LinqBinary)
{
return DbType.Binary;
}
if (typeof(IEnumerable).IsAssignableFrom(type)) if (typeof(IEnumerable).IsAssignableFrom(type))
{ {
// use xml to denote its a list, hacky but will work on any DB // use xml to denote its a list, hacky but will work on any DB
...@@ -926,7 +930,7 @@ private static CacheInfo GetCacheInfo(Identity identity) ...@@ -926,7 +930,7 @@ private static CacheInfo GetCacheInfo(Identity identity)
} }
#endif #endif
if (!typeMap.ContainsKey(type)) if (!(typeMap.ContainsKey(type) || type.FullName == LinqBinary))
{ {
return GetTypeDeserializer(type, reader, startBound, length, returnNullIfFirstMissing); return GetTypeDeserializer(type, reader, startBound, length, returnNullIfFirstMissing);
} }
...@@ -1314,9 +1318,9 @@ private static IEnumerable<PropertyInfo> FilterParameters(IEnumerable<PropertyIn ...@@ -1314,9 +1318,9 @@ private static IEnumerable<PropertyInfo> FilterParameters(IEnumerable<PropertyIn
il.MarkLabel(lenDone); il.MarkLabel(lenDone);
il.Emit(OpCodes.Stloc_1); // [string] il.Emit(OpCodes.Stloc_1); // [string]
} }
if (prop.PropertyType == typeof(System.Data.Linq.Binary)) if (prop.PropertyType.FullName == LinqBinary)
{ {
il.EmitCall(OpCodes.Callvirt, typeof(System.Data.Linq.Binary).GetMethod("ToArray", BindingFlags.Public | BindingFlags.Instance), null); il.EmitCall(OpCodes.Callvirt, prop.PropertyType.GetMethod("ToArray", BindingFlags.Public | BindingFlags.Instance), null);
} }
if (allDone != null) il.MarkLabel(allDone.Value); if (allDone != null) il.MarkLabel(allDone.Value);
// relative stack [boxed value or DBNull] // relative stack [boxed value or DBNull]
...@@ -1385,9 +1389,9 @@ private static int ExecuteCommand(IDbConnection cnn, IDbTransaction transaction, ...@@ -1385,9 +1389,9 @@ private static int ExecuteCommand(IDbConnection cnn, IDbTransaction transaction,
{ {
return r => SqlMapper.ReadNullableChar(r.GetValue(index)); return r => SqlMapper.ReadNullableChar(r.GetValue(index));
} }
if (type == typeof(System.Data.Linq.Binary)) if (type.FullName == LinqBinary)
{ {
return r => new System.Data.Linq.Binary((byte[])r.GetValue(index)); return r => Activator.CreateInstance(type, r.GetValue(index));
} }
#pragma warning restore 618 #pragma warning restore 618
return r => return r =>
...@@ -1582,10 +1586,10 @@ static List<FieldInfo> GetSettableFields(Type t) ...@@ -1582,10 +1586,10 @@ static List<FieldInfo> GetSettableFields(Type t)
il.MarkLabel(isNotString); il.MarkLabel(isNotString);
} }
if (memberType == typeof(System.Data.Linq.Binary)) if (memberType.FullName == LinqBinary)
{ {
il.Emit(OpCodes.Unbox_Any, typeof(byte[])); // stack is now [target][target][byte-array] il.Emit(OpCodes.Unbox_Any, typeof(byte[])); // stack is now [target][target][byte-array]
il.Emit(OpCodes.Newobj, typeof(System.Data.Linq.Binary).GetConstructor(new Type[] { typeof(byte[]) }));// stack is now [target][target][binary] il.Emit(OpCodes.Newobj, memberType.GetConstructor(new Type[] { typeof(byte[]) }));// stack is now [target][target][binary]
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment