LinqDataSourceSelectEventArgs.Result 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
데이터 쿼리에 사용되는 데이터 개체를 가져오거나 설정합니다.
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
속성 값
쿼리의 데이터를 나타내는 개체입니다.
예제
다음 예제에서는 LINQ 쿼리의 결과로 속성을 설정 Result 하는 방법을 보여 있습니다.
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 이외의 null값으로 설정되면 컨트롤이 LinqDataSource 속성에 TableName 정의된 개체를 쿼리하지 않습니다. 대신 속성의 개체 Result 를 쿼리합니다.
메모
속성을 개체로 Result 설정하는 경우 데이터를 포함하지 않는 개체를 나타내는 데 사용하지 null 마세요. 컨트롤은 LinqDataSource 속성이 Result 설정되지 않았다는 의미로 해석 null 되며 속성에서 TableName 개체를 만들고 쿼리합니다. 데이터가 포함되지 않은 개체를 나타내려면 요소를 포함하지 않는 개체 또는 IList<T> 속성 IList 으로 설정합니다Result.
ContextCreating속성을 개체로 프로그래밍 방식으로 설정하고 Result 두 가지 추가 조건이 적용되는 경우 , ContextCreated및 ContextDisposing 이벤트가 발생하지 않습니다. 조건은 원래 값을 뷰 상태에 저장할 필요가 없거나 속성의 Result 개체가 인터페이스를 ITable 구현한다는 것입니다.