Skip to content

Commit 609f63b

Browse files
committed
Merge remaining methods in target-specific files
1 parent cb5999a commit 609f63b

File tree

5 files changed

+80
-181
lines changed

5 files changed

+80
-181
lines changed

src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,6 @@
450450
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SqlDataRecord.cs">
451451
<Link>Microsoft\Data\SqlClient\Server\SqlDataRecord.cs</Link>
452452
</Compile>
453-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SqlDataRecord.netcore.cs">
454-
<Link>Microsoft\Data\SqlClient\Server\SqlDataRecord.netcore.cs</Link>
455-
</Compile>
456453
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SqlMetaData.cs">
457454
<Link>Microsoft\Data\SqlClient\Server\SqlMetaData.cs</Link>
458455
</Compile>

src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,6 @@
561561
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SqlDataRecord.cs">
562562
<Link>Microsoft\Data\SqlClient\Server\SqlDataRecord.cs</Link>
563563
</Compile>
564-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SqlDataRecord.netfx.cs">
565-
<Link>Microsoft\Data\SqlClient\Server\SqlDataRecord.netfx.cs</Link>
566-
</Compile>
567564
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SqlMetaData.cs">
568565
<Link>Microsoft\Data\SqlClient\Server\SqlMetaData.cs</Link>
569566
</Compile>

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SqlDataRecord.cs

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,21 @@ public virtual string GetDataTypeName(int ordinal)
5454
#if NET
5555
[return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)]
5656
#endif
57-
public virtual Type GetFieldType(int ordinal) => GetFieldTypeFrameworkSpecific(ordinal);
57+
public virtual Type GetFieldType(int ordinal)
58+
{
59+
SqlMetaData md = GetSqlMetaData(ordinal);
60+
61+
#if NETFRAMEWORK
62+
if (md.SqlDbType == SqlDbType.Udt)
63+
{
64+
return md.Type;
65+
}
66+
else
67+
#endif
68+
{
69+
return MetaType.GetMetaTypeFromSqlDbType(md.SqlDbType, false).ClassType;
70+
}
71+
}
5872

5973
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlDataRecord.xml' path='docs/members[@name="SqlDataRecord"]/GetValue/*' />
6074
public virtual object GetValue(int ordinal) => ValueUtilsSmi.GetValue200(_recordBuffer, ordinal, GetSmiMetaData(ordinal));
@@ -246,10 +260,73 @@ public virtual int GetSqlValues(object[] values)
246260

247261
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlDataRecord.xml' path='docs/members[@name="SqlDataRecord"]/SetValues/*' />
248262
// ISqlUpdateableRecord Implementation
249-
public virtual int SetValues(params object[] values) => SetValuesFrameworkSpecific(values);
263+
public virtual int SetValues(params object[] values)
264+
{
265+
if (values == null)
266+
{
267+
throw ADP.ArgumentNull(nameof(values));
268+
}
269+
270+
// Allow values array longer than FieldCount, just ignore the extra cells.
271+
int copyLength = (values.Length > FieldCount) ? FieldCount : values.Length;
272+
273+
ExtendedClrTypeCode[] typeCodes = new ExtendedClrTypeCode[copyLength];
274+
275+
// Verify all data values as acceptable before changing current state.
276+
for (int i = 0; i < copyLength; i++)
277+
{
278+
SqlMetaData metaData = GetSqlMetaData(i);
279+
typeCodes[i] = MetaDataUtilsSmi.DetermineExtendedTypeCodeForUseWithSqlDbType(
280+
metaData.SqlDbType,
281+
isMultiValued: false,
282+
values[i],
283+
metaData.Type);
284+
if (typeCodes[i] == ExtendedClrTypeCode.Invalid)
285+
{
286+
throw ADP.InvalidCast();
287+
}
288+
}
289+
290+
// Now move the data (it'll only throw if someone plays with the values array between
291+
// the validation loop and here, or if an invalid UDT was sent).
292+
for (int i = 0; i < copyLength; i++)
293+
{
294+
ValueUtilsSmi.SetCompatibleValueV200(
295+
_recordBuffer,
296+
ordinal: i,
297+
GetSmiMetaData(i),
298+
values[i],
299+
typeCodes[i],
300+
offset: 0,
301+
peekAhead: null);
302+
}
303+
304+
return copyLength;
305+
}
250306

251307
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlDataRecord.xml' path='docs/members[@name="SqlDataRecord"]/SetValue/*' />
252-
public virtual void SetValue(int ordinal, object value) => SetValueFrameworkSpecific(ordinal, value);
308+
public virtual void SetValue(int ordinal, object value)
309+
{
310+
SqlMetaData metaData = GetSqlMetaData(ordinal);
311+
ExtendedClrTypeCode typeCode = MetaDataUtilsSmi.DetermineExtendedTypeCodeForUseWithSqlDbType(
312+
metaData.SqlDbType,
313+
isMultiValued: false,
314+
value,
315+
metaData.Type);
316+
if (typeCode == ExtendedClrTypeCode.Invalid)
317+
{
318+
throw ADP.InvalidCast();
319+
}
320+
321+
ValueUtilsSmi.SetCompatibleValueV200(
322+
_recordBuffer,
323+
ordinal,
324+
GetSmiMetaData(ordinal),
325+
value,
326+
typeCode,
327+
offset: 0,
328+
peekAhead: null);
329+
}
253330

254331
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient.Server/SqlDataRecord.xml' path='docs/members[@name="SqlDataRecord"]/SetBoolean/*' />
255332
public virtual void SetBoolean(int ordinal, bool value) => ValueUtilsSmi.SetBoolean(_recordBuffer, ordinal, GetSmiMetaData(ordinal), value);

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SqlDataRecord.netcore.cs

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SqlDataRecord.netfx.cs

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)