- using (var ObjectContext = new AgentSystemEntities())
- {
- DateTime dt = new DateTime(1997, 1, 1);
- string entitySQL = "SELECT VALUE Users FROM Users WHERE Users.AddDateTime > @dt;";
- ObjectParameter[] ps = { new ObjectParameter("dt", dt) };
- ObjectQuery<Users> query = ObjectContext.CreateQuery<Users>(entitySQL,ps);
- string message = "执行的语句:" + query.CommandText + "\n\r";
- if (query.Count() > 0)
- {
- message += query.First().UserNames + "\n\r";
- }
- else
- {
- message += "没有数据\n\r";
- }
- MessageBox.Show(message);
- }
[Entity Framework]获取部分字段的查询
最新推荐文章于 2022-12-06 09:34:02 发布