运行出现错误:
输入字符串的格式不正确。
说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.FormatException: 输入字符串的格式不正确。
源错误:
行 99: else
行 100: {
行 101: list.AddRange(cursor.ToList());
行 102: }
行 103: return list;
|
DAL层
/// <summary> /// 把MongoCursor转换成List类型 /// </summary> /// <param name="cursor">文档游标</param> /// <param name="preprocess">预处理方法</param> /// <returns></returns> protected internal List<TDocument> CursorToList(MongoCursor<TDocument> cursor, PreprocessHandler<TDocument> preprocess) { List<TDocument> list = new List<TDocument>(30); bool isPreprocess = preprocess != null; if (isPreprocess) { foreach (TDocument document in cursor) { var doc = document; preprocess(ref doc); list.Add(doc); } } else { list.AddRange(cursor.ToList()); } return list; } #endregion #region 根据query查询集合 /// <summary> /// 根据query查询集合 /// </summary> /// <param name="query">条件</param> /// <param name="cursorSettings">查询参数</param> /// <param name="preprocess">预处理方法</param> /// <returns></returns> public List<TDocument> Find(IMongoQuery query, MongoCursorSettings cursorSettings, PreprocessHandler<TDocument> preprocess) { var list = new List<TDocument>(); Execute(delegate(MongoCollection<TDocument> mongoCollection) { var cursor = mongoCollection.Find(query); if (cursorSettings != null) { cursorSettings.Set(cursor); } list = CursorToList(cursor, preprocess); }); return list; } #endregion
BLL层
public string UserSelectList(string fields,string greps) { userage = new DAL_UserAgeManager(); QueryDocument query = new QueryDocument(); query.Add(fields, greps); List<Model_User> list = userage.Find(query, null, null); string strlist = userage.ListToDataTable(list).ToJson(); return strlist; }
UI层
string a = userage.UserSelectList("address","大庆"); Response.Write(a);
给query方法加一个游标参数