The post Max in LINQ Query in Entity Framework Core appeared first on OctopusCodes.
]]>using EntityFrameworkCore_ConsoleApp.Models;
namespace EntityFrameworkCore_ConsoleApp
{
public class Program
{
static void Main(string[] args)
{
using (var databaseContext = new DatabaseContext())
{
var max = (from product in databaseContext.Products
select product).Max(product => product.Price);
Console.WriteLine("Min: " + max);
}
}
}
}
Max: 43
You can use combination of Max method and Where as below:
using EntityFrameworkCore_ConsoleApp.Models;
namespace EntityFrameworkCore_ConsoleApp
{
public class Program
{
static void Main(string[] args)
{
using (var databaseContext = new DatabaseContext())
{
var max = (from product in databaseContext.Products
where product.Status == true
select product).Max(product => product.Price);
Console.WriteLine("Min: " + max);
}
}
}
}
Max: 19
You can use combination of Max method and Where and Select as below:
using EntityFrameworkCore_ConsoleApp.Models;
namespace EntityFrameworkCore_ConsoleApp
{
public class Program
{
static void Main(string[] args)
{
using (var databaseContext = new DatabaseContext())
{
var max = (from product in databaseContext.Products
where product.Status == true
select product.Price).Max();
Console.WriteLine("Min: " + max);
}
}
}
}
Max: 19
The post Max in LINQ Query in Entity Framework Core appeared first on OctopusCodes.
]]>The post Max Method in LINQ MeThods in Entity Framework Core appeared first on OctopusCodes.
]]>using EntityFrameworkCore_ConsoleApp.Models;
namespace EntityFrameworkCore_ConsoleApp
{
public class Program
{
static void Main(string[] args)
{
using (var databaseContext = new DatabaseContext())
{
var max = databaseContext.Products.Max(product => product.Price);
Console.WriteLine("Max: " + max);
}
}
}
}
Max: 43
You can use combination of Max method and Where method as below:
using EntityFrameworkCore_ConsoleApp.Models;
namespace EntityFrameworkCore_ConsoleApp
{
public class Program
{
static void Main(string[] args)
{
using (var databaseContext = new DatabaseContext())
{
var max = databaseContext.Products.Where(product => product.Status == true).Max(product => product.Price);
Console.WriteLine("Max: " + max);
}
}
}
}
Max: 19
You can use combination of Max method and Where method and Select method as below:
using EntityFrameworkCore_ConsoleApp.Models;
namespace EntityFrameworkCore_ConsoleApp
{
public class Program
{
static void Main(string[] args)
{
using (var databaseContext = new DatabaseContext())
{
var max = databaseContext.Products.Where(product => product.Status == true).Select(product => product.Price).Max();
Console.WriteLine("Max: " + max);
}
}
}
}
Max: 19
The post Max Method in LINQ MeThods in Entity Framework Core appeared first on OctopusCodes.
]]>