This commit is contained in:
@@ -28,8 +28,6 @@ Once that is done then can steam ahead on the biz objects but until I have the c
|
|||||||
IMMEDIATE ITEMS:
|
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
|
- 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)
|
- EventLogProcessor.AddEntry: CHANGE this to save the context itself and then change all callers to handle that (remove save)
|
||||||
|
|||||||
@@ -17,58 +17,43 @@ namespace AyaNova.Biz
|
|||||||
internal static class BizObjectNameFetcher
|
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)
|
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
|
//Returns existance status of object type and id specified in database
|
||||||
internal static string Name(AyaType aytype, long id, AyContext ct = null)
|
internal static string Name(AyaType aytype, long id, AyContext ct = null)
|
||||||
{
|
{
|
||||||
//new up a context??
|
throw new System.NotSupportedException("BizObjectNameFetcher:: Slow version, did you mean to call this one?");
|
||||||
if (ct == null)
|
// //new up a context??
|
||||||
{
|
// if (ct == null)
|
||||||
ct = ServiceProviderProvider.DBContext;
|
// {
|
||||||
}
|
// ct = ServiceProviderProvider.DBContext;
|
||||||
switch (aytype)
|
// }
|
||||||
{
|
// switch (aytype)
|
||||||
case AyaType.User:
|
// {
|
||||||
return ct.User.AsNoTracking().Where(m => m.Id == id).Select(m => m.Name).FirstOrDefault();
|
// case AyaType.User:
|
||||||
case AyaType.Widget:
|
// 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())
|
// default:
|
||||||
{
|
// throw new System.NotSupportedException($"AyaNova.BLL.BizObjectNameFetcher::Name type {aytype.ToString()} is not supported");
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user