Simple.Data 小式一刀

 private static readonly string SqlDbText = ConfigurationManager.ConnectionStrings["DbText206"].ConnectionString;

 public IEnumerable<Test> GetTests()
        {
            var db = Database.OpenNamedConnection("DbText206");
            // Test:表名  All()全部  OrderBy:排序 Id:列名
            var query = db.Test.All().OrderById();

            var result =new List<Test>();
            foreach (var item in query)
            {
                var test = new Test
                {
                    Id = item.Id,
                    Age = item.Age,
                    Name = item.Name
                };
                result.Add(test);
            }
            return result;
        }
```
posted @ 2016-06-22 18:30  游子善心  阅读(1)  评论(0编辑  收藏  举报  来源