학습
모듈
Work with queries in Dynamics 365 Business Central - Training
Learn how to work with the Query object in Dynamics 365 Business Central to join, filter, and aggregate data.
LoadWith를 사용하여 한 쿼리에서 여러 개체를 검색할 수 있습니다.
다음 코드에서는 LoadWith 메서드를 사용하여 Customer
및 Order
개체를 모두 검색합니다.
Northwnd db = new Northwnd(@"northwnd.mdf");
DataLoadOptions ds = new DataLoadOptions();
ds.LoadWith<Customer>(c => c.Orders);
ds.LoadWith<Order>(o => o.OrderDetails);
db.LoadOptions = ds;
var custQuery =
from cust in db.Customers
where cust.City == "London"
select cust;
foreach (Customer custObj in custQuery)
{
Console.WriteLine($"Customer ID: {custObj.CustomerID}");
foreach (Order ord in custObj.Orders)
{
Console.WriteLine($"\tOrder ID: {ord.OrderID}");
foreach (OrderDetail detail in ord.OrderDetails)
{
Console.WriteLine($"\t\tProduct ID: {detail.ProductID}");
}
}
}
Dim db As New Northwnd("c:\northwnd.mdf")
Dim ds As DataLoadOptions = New DataLoadOptions()
ds.LoadWith(Of Customer)(Function(c) c.Orders)
ds.LoadWith(Of Order)(Function(o) o.OrderDetails)
db.LoadOptions = ds
Dim custQuery = From cust In db.Customers() _
Where cust.City = "London" _
Select cust
For Each custObj In custQuery
Console.WriteLine("Customer ID: " & custObj.CustomerID)
For Each ord In custObj.Orders
Console.WriteLine(vbTab & "Order ID: " & ord.OrderID)
For Each detail In ord.OrderDetails
Console.WriteLine(vbTab & vbTab & _
"Product ID: {0}", detail.ProductID)
Next
Next
Next
학습
모듈
Work with queries in Dynamics 365 Business Central - Training
Learn how to work with the Query object in Dynamics 365 Business Central to join, filter, and aggregate data.
설명서
자세한 정보: 방법: 관련 데이터 필터링
자세한 정보: 방법: 관련 데이터의 검색 양 제어
자세히 알아보기: 데이터베이스 쿼리