- 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 + " ";
- if (query.Count() > 0)
- {
- message += query.First().UserNames + " ";
- }
- else
- {
- message += "没有数据 ";
- }
- MessageBox.Show(message);
- }