コード例 #1
0
ファイル: Program.cs プロジェクト: GoranGit/Database
        public static IEnumerable<Customer> GetAllCustomersWithOrderMadeIn1997ShipedToCanadaSQL()
        {
            string sqlQuery = "SELECT DISTINCT c.CompanyName FROM dbo.Customers c INNER JOIN dbo.Orders o ON o.CustomerID = c.CustomerID  WHERE o.OrderDate BETWEEN '1997-01-01 00:00:00' AND '1998-01-01 00:00:00' AND o.ShipCountry = 'Canada'";

            NorthwindEntities context = new NorthwindEntities();
            var result = context.Database.SqlQuery<Customer>(sqlQuery);
            return result;
        }
コード例 #2
0
ファイル: Repository.cs プロジェクト: GoranGit/Database
        public void Insert(Customer entity)
        {
            this.context.Customers.Add(entity);
            this.context.SaveChanges();
            disposeCounte++;

            if (disposeCounte % 100 == 0)
            {
                disposeCounte = 0;
                this.context.Dispose();
                this.context = new NorthwindEntities();
            }
        }
コード例 #3
0
ファイル: Repository.cs プロジェクト: GoranGit/Database
 public CustomerRepository()
 {
     this.context = new NorthwindEntities();
     this.disposeCounte = 0;
 }