using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using Microsoft.Data.SqlClient;
using Streamx.Linq.SQL.EFCore;
using Streamx.Linq.SQL.TransactSQL;
using static Streamx.Linq.SQL.SQL;
public static void Main()
using (var context = new EntityContext())
context.Database.EnsureCreated();
XLinq.Configuration.RegisterVendorCapabilities();
var ids = new List<int>() { 1, 2 };
var description = "Updated";
using (var context = new EntityContext())
context.Database.Query((Customer customer) => {
UPDATE(customer).SET(() => {
customer.IsActive = isActive;
customer.Description = description;
WHERE(ids.Contains(customer.CustomerID));
FiddleHelper.WriteTable(context.Customers.ToList());
public static void GenerateData()
using (var context = new EntityContext())
context.Customers.Add(new Customer() { Name ="Customer_A", Description = "Description", IsActive = true, LastLogin = new DateTime(2010,1,1) });
context.Customers.Add(new Customer() { Name ="Customer_B", Description = "Description", IsActive = true, LastLogin = new DateTime(2010,1,1) });
context.Customers.Add(new Customer() { Name ="Customer_C", Description = "Description", IsActive = true, LastLogin = DateTime.Now });
using (var context = new EntityContext())
FiddleHelper.WriteTable(context.Customers.ToList());
public class EntityContext : DbContext
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
optionsBuilder.UseSqlServer(new SqlConnection(FiddleHelper.GetConnectionStringSqlServer()));
base.OnConfiguring(optionsBuilder);
public DbSet<Customer> Customers { get; set; }
public int CustomerID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public DateTime LastLogin { get; set; }
public Boolean IsActive { get; set; }