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())); }
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)); }
/// <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)); }
/// <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)); }