3

私は DbCommandから使用しています: System.ComponentModel.Component

私はparamsでオブジェクトを構築しています:

DbCommand command = _webERPDB.GetStoredProcCommand("mySp");
_webERPDB.AddInParameter(command, "@a", DbType.Int32, policyId);
_webERPDB.AddInParameter(command, "@b", DbType.Int32, appPolicyPrintQaCheckListId);
_webERPDB.AddInParameter(command, "@c", DbType.Int32, createdBy);

そして今、私はlinqを使用してそれを繰り返したいと思います:

IEnumerable<DbParameter> t = from a in command.Parameters select a;

しかし、次のエラーが発生しています:

ここに画像の説明を入力してください

4

1 に答える 1

10
IEnumerable<DbParameter> t = command.Parameters.Cast<DbParameter>();

Cast<T>()のタイプParametersは、 (非ジェネリック)DbParameterCollectionを実装しますが、を実装しないため、使用する必要があります。あなたは書けるIEnumerableIEnumerable<T>

IEnumerable t = command.Parameters;
于 2012-01-05T10:25:05.957 に答える