DataObjectMethodAttribute 생성자

정의

DataObjectMethodAttribute 클래스의 새 인스턴스를 초기화합니다.

오버로드

DataObjectMethodAttribute(DataObjectMethodType)

DataObjectMethodAttribute 클래스의 새 인스턴스를 초기화하고 메서드가 수행하는 데이터 작업의 형식을 식별합니다.

DataObjectMethodAttribute(DataObjectMethodType, Boolean)

DataObjectMethodAttribute 클래스의 새 인스턴스를 초기화하고, 메서드가 수행하는 데이터 작업의 형식을 식별하며, 메서드가 데이터 개체에서 노출하는 기본 데이터 메서드인지 여부를 식별합니다.

DataObjectMethodAttribute(DataObjectMethodType)

Source:
DataObjectMethodAttribute.cs
Source:
DataObjectMethodAttribute.cs
Source:
DataObjectMethodAttribute.cs

DataObjectMethodAttribute 클래스의 새 인스턴스를 초기화하고 메서드가 수행하는 데이터 작업의 형식을 식별합니다.

public:
 DataObjectMethodAttribute(System::ComponentModel::DataObjectMethodType methodType);
public DataObjectMethodAttribute (System.ComponentModel.DataObjectMethodType methodType);
new System.ComponentModel.DataObjectMethodAttribute : System.ComponentModel.DataObjectMethodType -> System.ComponentModel.DataObjectMethodAttribute
Public Sub New (methodType As DataObjectMethodType)

매개 변수

methodType
DataObjectMethodType

메서드가 수행하는 데이터 작업을 설명하는 DataObjectMethodType 값 중 하나입니다.

예제

다음 코드 예제에서는 공개적으로 노출 된 메서드에 DataObjectMethodAttribute 특성을 적용 하 고 수행 하는 데이터 작업의 형식 및 형식의 기본 데이터 메서드 인지 여부를 식별 하는 방법을 보여 줍니다. 이 예제에서 형식은 NorthwindData 두 개의 데이터 메서드를 노출합니다. 하나는 라는 데이터 집합을 검색하고 다른 하나는 라는 GetAllEmployeesDeleteEmployeeByID데이터를 삭제합니다. 특성은 DataObjectMethodAttribute 두 메서드에 적용되고, GetAllEmployees 메서드는 데이터 선택 작업의 기본 메서드로 표시되고 DeleteEmployeeByID , 메서드는 데이터 삭제 작업의 기본 메서드로 표시됩니다.

[DataObjectAttribute]
public class NorthwindData
{  
  public NorthwindData() {}

  [DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
  public static IEnumerable GetAllEmployees()
  {
    AccessDataSource ads = new AccessDataSource();
    ads.DataSourceMode = SqlDataSourceMode.DataReader;
    ads.DataFile = "~//App_Data//Northwind.mdb";
    ads.SelectCommand = "SELECT EmployeeID,FirstName,LastName FROM Employees";
    return ads.Select(DataSourceSelectArguments.Empty);
  }

  // Delete the Employee by ID.
  [DataObjectMethodAttribute(DataObjectMethodType.Delete, true)]
  public void DeleteEmployeeByID(int employeeID)
  {
    throw new Exception("The value passed to the delete method is "
                         + employeeID.ToString());
  }
}
<DataObjectAttribute()> _
Public Class NorthwindData

  <DataObjectMethodAttribute(DataObjectMethodType.Select, True)> _
  Public Shared Function GetAllEmployees() As IEnumerable
    Dim ads As New AccessDataSource()
    ads.DataSourceMode = SqlDataSourceMode.DataReader
    ads.DataFile = "~/App_Data/Northwind.mdb"
    ads.SelectCommand = "SELECT EmployeeID,FirstName,LastName FROM Employees"
    Return ads.Select(DataSourceSelectArguments.Empty)
  End Function 'GetAllEmployees

  ' Delete the Employee by ID.
  <DataObjectMethodAttribute(DataObjectMethodType.Delete, True)> _
  Public Sub DeleteEmployeeByID(ByVal employeeID As Integer)
    Throw New Exception("The value passed to the delete method is " + employeeID.ToString())
  End Sub

End Class

설명

IsDefault 생성자를 사용하여 개체를 만들 때 속성이 DataObjectMethodAttributeDataObjectMethodAttribute(DataObjectMethodType) 설정 false 됩니다.

적용 대상

DataObjectMethodAttribute(DataObjectMethodType, Boolean)

Source:
DataObjectMethodAttribute.cs
Source:
DataObjectMethodAttribute.cs
Source:
DataObjectMethodAttribute.cs

DataObjectMethodAttribute 클래스의 새 인스턴스를 초기화하고, 메서드가 수행하는 데이터 작업의 형식을 식별하며, 메서드가 데이터 개체에서 노출하는 기본 데이터 메서드인지 여부를 식별합니다.

public:
 DataObjectMethodAttribute(System::ComponentModel::DataObjectMethodType methodType, bool isDefault);
public DataObjectMethodAttribute (System.ComponentModel.DataObjectMethodType methodType, bool isDefault);
new System.ComponentModel.DataObjectMethodAttribute : System.ComponentModel.DataObjectMethodType * bool -> System.ComponentModel.DataObjectMethodAttribute
Public Sub New (methodType As DataObjectMethodType, isDefault As Boolean)

매개 변수

methodType
DataObjectMethodType

메서드가 수행하는 데이터 작업을 설명하는 DataObjectMethodType 값 중 하나입니다.

isDefault
Boolean

특성이 적용되는 메서드가 지정된 methodType에 대한 데이터 개체의 기본 메서드임을 나타내려면 true이고, 그렇지 않으면 false입니다.

예제

다음 코드 예제에서는 공개적으로 노출 된 메서드에 DataObjectMethodAttribute 특성을 적용 하 고 수행 하는 데이터 작업의 형식 및 형식의 기본 데이터 메서드 인지 여부를 식별 하는 방법을 보여 줍니다. 이 예제에서 형식은 NorthwindData 두 개의 데이터 메서드를 노출합니다. 하나는 라는 데이터 집합을 검색하고 다른 하나는 라는 GetAllEmployeesDeleteEmployeeByID데이터를 삭제합니다. 특성은 DataObjectMethodAttribute 두 메서드에 적용되고, GetAllEmployees 메서드는 데이터 선택 작업의 기본 메서드로 표시되고 DeleteEmployeeByID , 메서드는 데이터 삭제 작업의 기본 메서드로 표시됩니다.

[DataObjectAttribute]
public class NorthwindData
{  
  public NorthwindData() {}

  [DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
  public static IEnumerable GetAllEmployees()
  {
    AccessDataSource ads = new AccessDataSource();
    ads.DataSourceMode = SqlDataSourceMode.DataReader;
    ads.DataFile = "~//App_Data//Northwind.mdb";
    ads.SelectCommand = "SELECT EmployeeID,FirstName,LastName FROM Employees";
    return ads.Select(DataSourceSelectArguments.Empty);
  }

  // Delete the Employee by ID.
  [DataObjectMethodAttribute(DataObjectMethodType.Delete, true)]
  public void DeleteEmployeeByID(int employeeID)
  {
    throw new Exception("The value passed to the delete method is "
                         + employeeID.ToString());
  }
}
<DataObjectAttribute()> _
Public Class NorthwindData

  <DataObjectMethodAttribute(DataObjectMethodType.Select, True)> _
  Public Shared Function GetAllEmployees() As IEnumerable
    Dim ads As New AccessDataSource()
    ads.DataSourceMode = SqlDataSourceMode.DataReader
    ads.DataFile = "~/App_Data/Northwind.mdb"
    ads.SelectCommand = "SELECT EmployeeID,FirstName,LastName FROM Employees"
    Return ads.Select(DataSourceSelectArguments.Empty)
  End Function 'GetAllEmployees

  ' Delete the Employee by ID.
  <DataObjectMethodAttribute(DataObjectMethodType.Delete, True)> _
  Public Sub DeleteEmployeeByID(ByVal employeeID As Integer)
    Throw New Exception("The value passed to the delete method is " + employeeID.ToString())
  End Sub

End Class

적용 대상