示例#1
0
 public void SaveTestData(TestData data)
 {
     if (data.TestDataID == 0)
     {
         context.TestDataDbSet.Add(data);
     }
     else
     {
         context.Entry(data).State = EntityState.Modified;
     }
     context.SaveChanges();
 }
示例#2
0
        static void Main(string[] args)
        {
            Test t = new Test();

            TestData td1 = new TestData()
            {
                TestName = "已提交数据",
                StockPoolStatus = new StatusWrapper()
                { 
                    EnumValue =  StatusEnum.AskFinish
                }
            };

            TestData td2 = new TestData()
            {
                TestName = "已关闭数据",
                StockPoolStatus = new StatusWrapper()
                {
                    EnumValue = StatusEnum.CloseFinish
                }
            };

            t.SaveTestData(td1);
            t.SaveTestData(td2);

            // 查询已关闭数据.
            var query =
                from data in t.TestDatas
                where data.StockPoolStatus.Value == (int)StatusEnum.CloseFinish
                select data;

            foreach (TestData td in query)
            {
                Console.WriteLine(td);
            }
            Console.ReadLine();
        }