EF的增删改查

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace EF_Exercise
{
    class Program
    {
        static void Main(string[] args)
        {
         Heima3DbShitEntities db = new Heima3DbShitEntities();
         Customer custom =new Customer();
            //添加实体
            db.Customer.AddObject(custom);
            //删除和修改 Id现行
            custom.ID = 22;
            db.ObjectStateManager.ChangeObjectState(custom, EntityState.Modified);
            db.ObjectStateManager.ChangeObjectState(custom, EntityState.Deleted);
            //Lambda查询
            var data = db.Customer.Where(t => t.ID > 10);
            //Linq查询
            var data1 = from c in db.Customer
                        where c.ID > 10
                        select c;
        }
    }
}
原文地址:https://www.cnblogs.com/nieyulin123/p/3149911.html