Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Commit

Permalink
Sample code to filter entities based on navigational property.
Browse files Browse the repository at this point in the history
  • Loading branch information
srpraveenkumar committed Jun 21, 2017
1 parent b264c8b commit 59db48e
Show file tree
Hide file tree
Showing 5 changed files with 5,988 additions and 6,390 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<Compile Include="ODataChangesetsExample.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="QuerySamples.cs" />
<Compile Include="QueryExamples.cs" />
<Compile Include="SimpleCRUDExamples.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions ServiceSamples/ODataConsoleApplication/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ static void Main(string[] args)
// QueryExamples.SortSyntax(context);
// QueryExamples.FilterByCompany(context);
// QueryExamples.ExpandNavigationalProperty(context);


// 2. Simple CRUD examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static void FilterByCompany(Resources d365)

public static void ExpandNavigationalProperty(Resources d365Client)
{
var salesOrdersWithLines = d365Client.SalesOrderHeaders.Expand("SalesOrderLine").Where(x => x.SalesOrderNumber == "012518").Take(5);
var salesOrdersWithLines = d365Client.SalesOrderHeaders.Expand("SalesOrderLine").Where(x => x.SalesOrderNumber == "012518" ).Take(5);

foreach(var salesOrder in salesOrdersWithLines)
{
Expand All @@ -89,9 +89,19 @@ public static void ExpandNavigationalProperty(Resources d365Client)
foreach( var salesLine in salesOrder.SalesOrderLine)
{
Console.WriteLine(string.Format("Sales order line with description {0} contains item id {1}", salesLine.LineDescription, salesLine.ItemNumber));
}

}
}
}

public static void FilterOnNavigationalProperty(Resources d365Client)
{
var salesOrderLines = d365Client.SalesOrderLines.Where(x => x.SalesOrderHeader.SalesOrderStatus == SalesStatus.Invoiced);

foreach (var salesOrderLine in salesOrderLines)
{
Console.WriteLine(salesOrderLine.ItemNumber);
}

}
}
}
Loading

0 comments on commit 59db48e

Please sign in to comment.