The post Min 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 min = (from product in databaseContext.Products
select product).Min(product => product.Price);
Console.WriteLine("Min: " + min);
}
}
}
}
Min: 4
You can use combination of Min 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 min = (from product in databaseContext.Products
where product.Status == true
select product).Min(product => product.Price);
Console.WriteLine("Min: " + min);
}
}
}
}
Min: 10
You can use combination of Min 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 min = (from product in databaseContext.Products
where product.Status == true
select product.Price).Min();
Console.WriteLine("Min: " + min);
}
}
}
}
Min: 10
The post Min in LINQ Query in Entity Framework Core appeared first on OctopusCodes.
]]>The post Min 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 min = databaseContext.Products.Min(product => product.Price);
Console.WriteLine("Min: " + min);
}
}
}
}
Min: 4
You can use combination of Min 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 min = databaseContext.Products.Where(product => product.Status == true).Min(product => product.Price);
Console.WriteLine("Min: " + min);
}
}
}
}
Min: 10
You can use combination of Min 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 min = databaseContext.Products.Where(product => product.Status == true).Select(product => product.Price).Min();
Console.WriteLine("Min: " + min);
}
}
}
}
Min: 10
The post Min Method in LINQ MeThods in Entity Framework Core appeared first on OctopusCodes.
]]>