다음 함수가 있습니다.C#에서 객체에 속성을 추가 할 수 있습니까?
public static void UpdateWithStoredProcedure<T>(string storedProcedure, T entity)
{
var command = PrepareCommand(CommandType.StoredProcedure);
command.CommandText = storedProcedure;
AddObjectPropertiesAsParametersToCommand(command, entity);
command.ExecuteNonQuery();
}
이 방법은
라고합니다.UpdateWithStoredProcedure(DeleteDocumentStyleProcedure, new KeyValuePair<string, object>("Id", DocumentStyle.DocumentId));
두 개의 매개 변수를 전달하는 방법이 있습니까? 두 개의 KeyValuePair 인스턴스가 있습니까? 목록과 사전을 전달하려고했지만 AddObjectPropertiesAsParametersToCommand의 코드는 Count와 같은이 클래스의 내부 속성도 매핑합니다.
'AddObjectPropertiesAsParametersToCommand'는 무엇입니까? – Gabe
정말 "AddObjectPropertiesAsParametersToCommand"메서드를 변경해야하는 것 같습니다. 그것을 볼 수 없다면 배열을 전달하는 것은 어떨까요? – David
AddObjectPropertiesAsParametersToCommand를 변경할 수 없습니다. 그것이하는 일은 모든 객체 속성을 반복하고 값을 얻는 것입니다. 리플렉션 사용을 믿습니다. – Omar