Example #1
0
 public static T Instance <T>(this MongoDBRef instance) where T : IEntity
 {
     if (instance == null || null == instance.Id || string.IsNullOrEmpty(instance.CollectionName))
     {
         return(default(T));
     }
     return(EntityOperationExtensions.DBFind <T>(instance.Id.ToString()));
 }
Example #2
0
 public static T RefPick <T>(this List <MongoDBRef> lst, string id) where T : IEntity
 {
     if (lst == null)
     {
         return(default(T));
     }
     if (!lst.Exists(l => l.Id == id && l.CollectionName == typeof(T).DBCollectionName()))
     {
         return(default(T));
     }
     return(EntityOperationExtensions.DBFind <T>(id));
 }
Example #3
0
 /// <summary>
 /// 获取一个实例
 /// </summary>
 /// <typeparam name="T">类型</typeparam>
 /// <param name="where">查询表达式</param>
 /// <returns></returns>
 public static T Get <T>(Expression <Func <T, bool> > where) where T : IEntity
 {
     IsTypeCanBeUsed(typeof(T));
     return(EntityOperationExtensions.DBFind <T>(where));
 }
Example #4
0
 /// <summary>
 /// 获取一个实例
 /// </summary>
 /// <typeparam name="T">类型</typeparam>
 /// <param name="id">id</param>
 /// <returns></returns>
 public static T Get <T>(string id) where T : IEntity
 {
     IsTypeCanBeUsed(typeof(T));
     return(EntityOperationExtensions.DBFind <T>(id));
 }