日期:2014-05-17 浏览次数:20550 次
public List<User> SelectByName(string name) { using (CleverTourEntities context = new CleverTourEntities()) //CleverTourEntities context = new CleverTourEntities(); { var user = from u in context.User where u.Name == name select u; //UserList = user.ToList(); return user.ToList(); } }
public static string EntityToJson(object o) { //设置Json序列化格式 JsonSerializer js = new JsonSerializer(); //JSON中的Key名称采用驼峰命名法,且首字母小写 js.ContractResolver = new CamelCasePropertyNamesContractResolver(); string rtn = ""; rtn = JArray.FromObject(o, js).ToString(); return rtn; }
public List<User> SelectByName(string name) { List<User> users = new List<User>(); using (CleverTourEntities context = new CleverTourEntities()) //CleverTourEntities context = new CleverTourEntities(); { var user = from u in context.User where u.Name == name select u; //UserList = user.ToList(); users = user.ToList(); } return users; }
------解决方案--------------------
如果问题依然没有解决 可以看下你的类里是否有导航属性
把导航属性 加上这个特性 JsonIgnore