public List <G_Image> GetEntities(IList <string> names) { var entities = new List <G_Image>(); if (names.Count > 0) { var cmds = new string[names.Count]; for (var i = 0; i < cmds.Length; i++) { cmds[i] = string.Format("SELECT N'{0}' AS [Name]", names[i]); } var sql = String.Format(@" ;WITH T AS ( {0} ) SELECT I.[Name],I.[Type],I.[Content],I.[Thumbnail],I.[UpdateMark],I.[Remark] FROM [dbo].[G_Images] I INNER JOIN T ON I.[Name] = T.[Name];", string.Join(" UNION ALL ", cmds)); using (var rdr = SqlHelper.ExecuteReader(this._databaseConnectionString, CommandType.Text, sql, null)) { while (rdr.Read()) { var entity = new G_Image(); entity.Name = SqlTypeConverter.DBNullStringHandler(rdr["Name"]); entity.Type = SqlTypeConverter.DBNullInt32Handler(rdr["Type"]); entity.Content = SqlTypeConverter.DBNullBytesHandler(rdr["Content"]); entity.Thumbnail = SqlTypeConverter.DBNullBytesHandler(rdr["Thumbnail"]); entity.UpdateMark = SqlTypeConverter.DBNullStringHandler(rdr["UpdateMark"]); entity.Remark = SqlTypeConverter.DBNullStringHandler(rdr["Remark"]); entities.Add(entity); } } } return(entities); }
public String SaveGVImage([FromBody] API_GV_ImagePair image) { try { if (image == null) { throw new ArgumentNullException("image"); } var target = new G_Image { Name = image.Name, Type = image.Type, Content = JsonConvert.DeserializeObject <byte[]>(image.Source), Thumbnail = JsonConvert.DeserializeObject <byte[]>(image.Min), UpdateMark = image.UpdateMark }; if (_gimageService.Exist(image.Name)) { _gimageService.Update(target); } else { _gimageService.Add(target); } } catch (Exception exc) { return(exc.Message); } return(null); }
public List <G_Image> GetNames() { var entities = new List <G_Image>(); using (var rdr = SqlHelper.ExecuteReader(this._databaseConnectionString, CommandType.Text, SqlCommands_Sc.Sql_G_Image_Repository_GetNames, null)) { while (rdr.Read()) { var entity = new G_Image(); entity.Name = SqlTypeConverter.DBNullStringHandler(rdr["Name"]); entity.Type = SqlTypeConverter.DBNullInt32Handler(rdr["Type"]); entity.UpdateMark = SqlTypeConverter.DBNullStringHandler(rdr["UpdateMark"]); entity.Remark = SqlTypeConverter.DBNullStringHandler(rdr["Remark"]); entities.Add(entity); } } return(entities); }
public G_Image GetEntity(string name) { SqlParameter[] parms = { new SqlParameter("@Name", SqlDbType.VarChar, 200) }; parms[0].Value = SqlTypeConverter.DBNullStringChecker(name); G_Image entity = null; using (var rdr = SqlHelper.ExecuteReader(this._databaseConnectionString, CommandType.Text, SqlCommands_Sc.Sql_G_Image_Repository_GetEntity, parms)) { if (rdr.Read()) { entity = new G_Image(); entity.Name = SqlTypeConverter.DBNullStringHandler(rdr["Name"]); entity.Type = SqlTypeConverter.DBNullInt32Handler(rdr["Type"]); entity.Content = SqlTypeConverter.DBNullBytesHandler(rdr["Content"]); entity.Thumbnail = SqlTypeConverter.DBNullBytesHandler(rdr["Thumbnail"]); entity.UpdateMark = SqlTypeConverter.DBNullStringHandler(rdr["UpdateMark"]); entity.Remark = SqlTypeConverter.DBNullStringHandler(rdr["Remark"]); } } return(entity); }