This commit is contained in:
2018-10-04 20:56:40 +00:00
parent 179cc0a522
commit 7ea5c911aa
6 changed files with 24 additions and 18 deletions

View File

@@ -28,6 +28,7 @@ namespace AyaNova.Biz
internal static string Name(AyaType aytype, long id, System.Data.Common.DbCommand cmd)
{
string TABLE = string.Empty;
string COLUMN = "name";
switch (aytype)
{
case AyaType.User:
@@ -42,10 +43,14 @@ namespace AyaNova.Biz
case AyaType.TagGroup:
TABLE = "ataggroup";
break;
case AyaType.FileAttachment:
TABLE = "afileattachment";
COLUMN = "displayfilename";
break;
default:
throw new System.NotSupportedException($"AyaNova.BLL.BizObjectNameFetcher::Name type {aytype.ToString()} is not supported");
}
cmd.CommandText = $"SELECT m.name FROM {TABLE} AS m WHERE m.id = {id} LIMIT 1";
cmd.CommandText = $"SELECT m.{COLUMN} FROM {TABLE} AS m WHERE m.id = {id} LIMIT 1";
using (var dr = cmd.ExecuteReader())
return dr.Read() ? dr.GetString(0) : "UNKNOWN";
}