Ejemplo n.º 1
0
 /// <summary>
 /// 加载一个GridFS文件
 /// </summary>
 /// <param name="id">文件id</param>
 /// <returns></returns>
 public static IMongoFile LoadFile <TMongoFileType>(string id) where TMongoFileType : IMongoFile
 {
     if (!id.IsMongoId())
     {
         return(null);
     }
     return(new MongoFile <TMongoFileType>(EntityOperationExtensions.DBLoadGridFS <TMongoFileType>((BsonValue)id)));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 加载文件集
        /// </summary>
        /// <param name="remoteFileName">存储文件名</param>
        /// <returns></returns>
        public static List <IMongoFile> LoadAllFiles <TMongoFileType>(string remoteFileName) where TMongoFileType : IMongoFile
        {
            List <IMongoFile> files = new List <IMongoFile>();

            if (string.IsNullOrEmpty(remoteFileName))
            {
                return(files);
            }
            var infos = EntityOperationExtensions.DBLoadGridFS <TMongoFileType>(remoteFileName);

            if (infos.Count == 0)
            {
                return(files);
            }
            infos.ForEach(delegate(MongoGridFSFileInfo info)
            {
                files.Add(new MongoFile <TMongoFileType>(info));
            });
            return(files);
        }