提交 67d0ac67 编写于 作者: M mgravell

remove System.Data.Linq ref

上级 f333c2f0
......@@ -36,7 +36,6 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Data.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Dapper\Properties\AssemblyInfo.cs">
......
......@@ -38,7 +38,6 @@
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Data.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="SqlMapper.cs" />
......
......@@ -294,9 +294,9 @@ static SqlMapper()
typeMap[typeof(Guid?)] = DbType.Guid;
typeMap[typeof(DateTime?)] = DbType.DateTime;
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)
{
DbType dbType;
......@@ -310,6 +310,10 @@ private static DbType LookupDbType(Type type, string name)
{
return dbType;
}
if (type.FullName == LinqBinary)
{
return DbType.Binary;
}
if (typeof(IEnumerable).IsAssignableFrom(type))
{
// use xml to denote its a list, hacky but will work on any DB
......@@ -926,7 +930,7 @@ private static CacheInfo GetCacheInfo(Identity identity)
}
#endif
if (!typeMap.ContainsKey(type))
if (!(typeMap.ContainsKey(type) || type.FullName == LinqBinary))
{
return GetTypeDeserializer(type, reader, startBound, length, returnNullIfFirstMissing);
}
......@@ -1314,9 +1318,9 @@ private static IEnumerable<PropertyInfo> FilterParameters(IEnumerable<PropertyIn
il.MarkLabel(lenDone);
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);
// relative stack [boxed value or DBNull]
......@@ -1385,9 +1389,9 @@ private static int ExecuteCommand(IDbConnection cnn, IDbTransaction transaction,
{
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
return r =>
......@@ -1582,10 +1586,10 @@ static List<FieldInfo> GetSettableFields(Type t)
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.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
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册