Working on Chap10
parent
d9e8bf8553
commit
2fe2761d0b
|
@ -0,0 +1,13 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider ignored files
|
||||
/contentModel.xml
|
||||
/.idea.WorkingWithEFCore.iml
|
||||
/modules.xml
|
||||
/projectSettingsUpdater.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="accountSettings">
|
||||
<option name="activeRegion" value="us-east-1" />
|
||||
<option name="recentlyUsedRegions">
|
||||
<list>
|
||||
<option value="us-east-1" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="Microsoft SQL Server - @localhost" uuid="4b4ea279-159d-49a1-9d2c-0fafe90fec40">
|
||||
<driver-ref>sqlserver.ms</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbc-driver>
|
||||
<jdbc-url>jdbc:sqlserver://localhost</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||
</project>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -3,6 +3,7 @@ using Packt.Shared;
|
|||
|
||||
Console.WriteLine($"Using {ProjectConstants.DatabaseProvider} database provider.");
|
||||
QueryingCategories();
|
||||
FilteredIncludes();
|
||||
|
||||
static void QueryingCategories()
|
||||
{
|
||||
|
@ -24,3 +25,29 @@ static void QueryingCategories()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void FilteredIncludes()
|
||||
{
|
||||
using (Northwind db = new())
|
||||
{
|
||||
Console.Write("Enter a minimum for units in stock: ");
|
||||
string unitsInStock = Console.ReadLine() ?? "10";
|
||||
int stock = int.Parse(unitsInStock);
|
||||
IQueryable<Category>? categories = db.Categories?
|
||||
.Include(c => c.Products.Where(p => p.Stock >= stock));
|
||||
if (categories is null)
|
||||
{
|
||||
Console.WriteLine("No categories found.");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (Category c in categories)
|
||||
{
|
||||
Console.WriteLine($"{c.CategoryName} has {c.Products.Count} products with a minimum of {stock} units in stock.");
|
||||
foreach (Product p in c.Products)
|
||||
{
|
||||
Console.WriteLine($" {p.ProductName} has {p.Stock} units in stock.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue