LinqDataSourceSelectEventArgs.Result 속성

정의

데이터 쿼리에 사용되는 데이터 개체를 가져오거나 설정합니다.

public:
 property System::Object ^ Result { System::Object ^ get(); void set(System::Object ^ value); };
public object Result { get; set; }
member this.Result : obj with get, set
Public Property Result As Object

속성 값

쿼리의 데이터를 나타내는 개체입니다.

예제

다음 예제에서는 설정 하는 방법의 Result LINQ 쿼리의 결과에 속성입니다.

protected void LinqDataSource_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
    ExampleDataContext exampleContext = new ExampleDataContext();
    
    e.Result = from p in exampleContext.Products 
         where p.Category == "Beverages"
         select new {
           ID = p.ProductID,
           Name = p.Name
         };
}
Protected Sub LinqDataSource_Selecting(sender As Object, e As LinqDataSourceSelectEventArgs)
    Dim exampleContext As New ExampleDataContext()

    e.Result = From p In exampleContext.Products Where p.Category = "Beverages"
               Select New With { _
                    Key .ID = p.ProductID, _
                    Key .Name = p.Name _
    }
End Sub

다음 예제에서는 설정 하는 방법을 보여 줍니다는 Result 속성 문자열 값의 배열에는 웹 페이지에 정의 되어 있습니다.

public partial class Default3 : System.Web.UI.Page
{
    string[] citiesArray = 
    { 
        "Atlanta", 
        "Charlotte", 
        "Denver", 
        "New York", 
        "San Francisco" 
    };

    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void LinqDataSource_Selecting(object sender, LinqDataSourceSelectEventArgs e)
    {
        var cities = from city in citiesArray
                     where city.CompareTo("B") > 0
                     select city;
        e.Result = cities;
        // Or we could set e.Result = citiesArray to return all rows.
    }
}
Partial Class Default3
    Inherits System.Web.UI.Page

    Dim citiesArray() As String = _
    { _
        "Atlanta", _
        "Charlotte", _
        "Denver", _
        "New York", _
        "San Francisco" _
    }


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       
    End Sub

    
    Protected Sub LinqDataSource_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceSelectEventArgs) Handles LinqDataSource1.Selecting
        Dim cities = From city In citiesArray _
                     Where city > "B" _
                     Select city
        e.Result = cities
        ' Or we could set e.Result = citiesArray to return all rows.
    End Sub
    
End Class

설명

기본적으로 LinqDataSource 컨트롤에 정의 된 개체는 쿼리 식에 적용 됩니다는 TableName 속성입니다. 대 한 처리기를 Selecting 이벤트를 수동으로 변경할 수 있습니다 설정 하 여 쿼리 되는 개체는 Result 개체 속성입니다. 예를 들어 사용할 수 있습니다는 Result LINQ 쿼리 식의 결과 얻기 위해 속성을 웹 페이지에 메모리 내 컬렉션을 쿼리 합니다. 설정할 수 있습니다는 Result 개체 속성입니다. 개체를 구현 하지 않는 경우는 IEnumerable<T> 인터페이스를를 LinqDataSource 컨트롤에서 구현 하는 개체에 개체를 래핑하는 IEnumerable<T> 인터페이스.

경우는 Result 속성 이외의 다른 값으로 설정 됩니다 nullLinqDataSource 컨트롤에 정의 된 개체를 쿼리하지 않습니다는 TableName 속성입니다. 개체 쿼리는 Result 속성입니다.

참고

설정한 경우 합니다 Result 개체에 속성을 사용 하지 않는 null 모든 데이터를 포함 하지 않는 개체를 나타내는입니다. LinqDataSource 해석할지 null 않는다는 것을 의미 하는 Result 속성을 설정 하지 않으면 및를 만들고 개체를 쿼리 합니다 TableName 속성. 데이터를 포함 하지 않는 개체를 표시, 설정 합니다 Result 속성을는 IList 또는 IList<T> 모든 요소를 포함 하지 않는 개체입니다.

합니다 ContextCreating, ContextCreated, 및 ContextDisposing 프로그래밍 방식으로 설정 하면 이벤트가 발생 하지 않습니다는 Result 속성 개체에 두 개의 추가 조건이 적용 될 때입니다. 조건에 해당 원래 값 보기 상태에 있거나 개체에 저장할 필요가 없습니다 합니다 Result 속성이 구현 하는 ITable 인터페이스입니다.

적용 대상

추가 정보