using System.Collections.Generic;
using System.Data.Entity;
using System.Linq.Dynamic.Core;
public static void Main()
var context = new EntityContext();
var totalPriceExample1 = context.Orders.Select("Price * Amount").Sum();
Console.WriteLine("totalPriceExample1 = {0}", totalPriceExample1);
var totalPriceExample2 = context.Orders.Sum("Price * Amount");
Console.WriteLine("totalPriceExample2 = {0}", totalPriceExample2);
public static void GenerateData()
var orders = new List<Order>
new Order { Amount = 5, Price = 3 },
new Order { Amount = 10, Price = 8 }
using (var context = new EntityContext())
context.Orders.AddRange(orders);
context.BulkSaveChanges();
public class EntityContext : DbContext
public EntityContext() : base(FiddleHelper.GetConnectionStringSqlServer())
public DbSet<Order> Orders { get; set; }
public int Id { get; set; }
public int Amount { get; set; }
public double Price { get; set; }
public int Id { get; set; }
public string Name { get; set; }
public string CompanyName { get; set; }
public string City { get; set; }
public string Phone { get; set; }