From fc8ea400297bd9d0ec0301ebe872e6b5faff8990 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 4 Oct 2018 22:30:31 +0000 Subject: [PATCH] --- devdocs/todo.txt | 2 - server/AyaNova/biz/BizObjectNameFetcher.cs | 71 +++++++++------------- 2 files changed, 28 insertions(+), 45 deletions(-) diff --git a/devdocs/todo.txt b/devdocs/todo.txt index fb7231a1..ee670ec7 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -28,8 +28,6 @@ Once that is done then can steam ahead on the biz objects but until I have the c IMMEDIATE ITEMS: ================ - - see if any other callers to name fetcher are in tight loops and could benefit from using the new Direct version - - Schema: clean up all the LOOKAT items and verify the indexes are being used - EventLogProcessor.AddEntry: CHANGE this to save the context itself and then change all callers to handle that (remove save) diff --git a/server/AyaNova/biz/BizObjectNameFetcher.cs b/server/AyaNova/biz/BizObjectNameFetcher.cs index c99b3b00..6a113d1a 100644 --- a/server/AyaNova/biz/BizObjectNameFetcher.cs +++ b/server/AyaNova/biz/BizObjectNameFetcher.cs @@ -17,58 +17,43 @@ namespace AyaNova.Biz internal static class BizObjectNameFetcher { + /* + NOT SURE IF I WILL WANT TO USE THIS OR NOT GOING FORWARD SO KEEPING IT IN PLACE BUT NOT USABLE FOR NOW + + */ + internal static string Name(AyaTypeId tid, AyContext ct = null) { - return Name(tid.ObjectType, tid.ObjectId, ct); + throw new System.NotSupportedException("BizObjectNameFetcher:: Slow version, did you mean to call this one?"); + //return Name(tid.ObjectType, tid.ObjectId, ct); } //Returns existance status of object type and id specified in database internal static string Name(AyaType aytype, long id, AyContext ct = null) { - //new up a context?? - if (ct == null) - { - ct = ServiceProviderProvider.DBContext; - } - switch (aytype) - { - case AyaType.User: - return ct.User.AsNoTracking().Where(m => m.Id == id).Select(m => m.Name).FirstOrDefault(); - case AyaType.Widget: - { + throw new System.NotSupportedException("BizObjectNameFetcher:: Slow version, did you mean to call this one?"); + // //new up a context?? + // if (ct == null) + // { + // ct = ServiceProviderProvider.DBContext; + // } + // switch (aytype) + // { + // case AyaType.User: + // return ct.User.AsNoTracking().Where(m => m.Id == id).Select(m => m.Name).FirstOrDefault(); + // case AyaType.Widget: + // return ct.Widget.AsNoTracking().Where(m => m.Id == id).Select(m => m.Name).FirstOrDefault(); + // case AyaType.Tag: + // return ct.Tag.AsNoTracking().Where(m => m.Id == id).Select(m => m.Name).FirstOrDefault(); + // case AyaType.TagGroup: + // return ct.TagGroup.AsNoTracking().Where(m => m.Id == id).Select(m => m.Name).FirstOrDefault(); + // case AyaType.FileAttachment: + // return ct.FileAttachment.AsNoTracking().Where(m => m.Id == id).Select(m => m.DisplayFileName).FirstOrDefault(); - using (var command = ct.Database.GetDbConnection().CreateCommand()) - { - command.CommandText = $"SELECT m.name FROM awidget AS m WHERE m.id = {id} LIMIT 1"; - ct.Database.OpenConnection(); - using (var dr = command.ExecuteReader()) - { - - // do something with result - return dr.Read() ? dr.GetString(0) : "UNKNOWN"; - } - } - - // var ret = ct.Widget - // .FromSql($"SELECT m.name FROM awidget AS m WHERE m.id = {id} LIMIT 1") - // .FirstOrDefault(); - // return ret.Name; - - - - // return ct.Widget.AsNoTracking().Where(m => m.Id == id).Select(m => m.Name).FirstOrDefault(); - } - case AyaType.Tag: - return ct.Tag.AsNoTracking().Where(m => m.Id == id).Select(m => m.Name).FirstOrDefault(); - case AyaType.TagGroup: - return ct.TagGroup.AsNoTracking().Where(m => m.Id == id).Select(m => m.Name).FirstOrDefault(); - case AyaType.FileAttachment: - return ct.FileAttachment.AsNoTracking().Where(m => m.Id == id).Select(m => m.DisplayFileName).FirstOrDefault(); - - default: - throw new System.NotSupportedException($"AyaNova.BLL.BizObjectNameFetcher::Name type {aytype.ToString()} is not supported"); - } + // default: + // throw new System.NotSupportedException($"AyaNova.BLL.BizObjectNameFetcher::Name type {aytype.ToString()} is not supported"); + // } }