|
using System;
using System.ComponentModel;
namespace BrainTechLLC.DAL
{
public partial class DBLayer<T> : INotifyPropertyChanged, ISuppliesID where T : DBLayer<T>, IDBLayer<T>, new()
{
public static LookupCollection<T> Find
{
get
{
if (Cache == null) EnsureInitialized();
return Cache.Find;
}
}
// Supports generic retrieval of objects by unique key - implements ISuppliesID interface
public DBLayer<T2> Get<T2>(int id) where T2 : DBLayer<T2>, IDBLayer<T2>, new() { return Get(id) as DBLayer<T2>; }
public object GetObject(int id) { return DBLayer<T>.Find[id]; }
public static T Get(int id) { return Find[id]; }
public DBLayer<T2> Get<T2>(long id) where T2 : DBLayer<T2>, IDBLayer<T2>, new() { return Get(id) as DBLayer<T2>; }
public long GetID() { PropertyDescriptor pd = CachedAttributes.QuickLookupProperty; return (pd == null) ? 0 : Convert.ToInt64(pd.GetValue(this)); }
public object GetObject(long id) { return DBLayer<T>.Find[id]; }
public static T Get(long id) { return Find[id]; }
// Note - below method will throw an unhandled exception if the friendly object name property has a null value
public string FriendlyObjectName { get { PropertyDescriptor pd = CachedAttributes.ObjectFriendlyNameProperty; return (pd == null) ? "" : Convert.ToString(pd.GetValue(this)); } }
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Currently working as a Senior Silverlight Developer with Troppus Software in Superior, CO. I enjoy statistics, programming, new technology, playing the cello, and reading codeproject articles.