示例#1
0
 /// <summary>
 /// 根据查询条件获取一条数据
 /// </summary>
 /// <typeparam name="T">数据类型</typeparam>
 /// <param name="collectionName">集合名称</param>
 /// <param name="query">查询条件,调用示例:Query.Matches("Title", "感冒") 或者 Query.EQ("Title", "感冒") 或者Query.And(Query.Matches("Title", "感冒"),Query.EQ("Author", "yanc"))</param>
 /// <returns>数据对象</returns>
 public static T GetOneByCondition <T>(string collectionName, MongoDB.Driver.IMongoQuery query) where T : IEntity <string>
 {
     return(MongoDbHepler.GetOneByCondition <T>(nosqlConnectionString, nosqlDbName, collectionName, query));
 }
示例#2
0
 /// <summary>
 /// 根据查询条件获取一条数据
 /// </summary>
 /// <typeparam name="T">数据类型</typeparam>
 /// <param name="collectionName">集合名称</param>
 /// <param name="query">查询条件,调用示例:Query.Matches("Title", "感冒") 或者 Query.EQ("Title", "感冒") 或者Query.And(Query.Matches("Title", "感冒"),Query.EQ("Author", "yanc"))</param>
 /// <returns>数据对象</returns>
 public static T GetOneByCondition <T>(string collectionName, IMongoQuery query)
 {
     return(MongoDbHepler.GetOneByCondition <MongoModel <T> >(nosqlConnectionString, nosqlDbName, collectionName, query).Data);
 }