progress
This commit is contained in:
@ -9,7 +9,7 @@ namespace COA.EnterpriseServices.DataAccess
|
||||
{
|
||||
public Creditor GetCreditor(int id)
|
||||
{
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
|
||||
namespace COA.EnterpriseServices.DataAccess
|
||||
{
|
||||
@ -14,4 +16,56 @@ namespace COA.EnterpriseServices.DataAccess
|
||||
|
||||
ICollection<T> Get(Expression<Func<T, bool>> query);
|
||||
}
|
||||
|
||||
//public class AggregateDataAccess<T> : IDataAccess<T> where T : class, IRecord
|
||||
//{
|
||||
// private static ICollection<Type> dataAccessTypes;
|
||||
|
||||
// static AggregateDataAccess() => LoadInstances();
|
||||
|
||||
// /// <summary>
|
||||
// /// Invokes a method for all instances of <typeparamref name="T"/>
|
||||
// /// </summary>
|
||||
// /// <typeparam name="TResult"></typeparam>
|
||||
// /// <param name="func"></param>
|
||||
// /// <returns></returns>
|
||||
// protected TResult Invoke<TResult>(Func<IDataAccess<T>, TResult> func)
|
||||
// {
|
||||
// var results = new List<TResult>();
|
||||
|
||||
// foreach (var dataAccessType in dataAccessTypes)
|
||||
// {
|
||||
// var instance = Activator.CreateInstance(dataAccessType) as IDataAccess<T>;
|
||||
|
||||
// results.Add(func(instance));
|
||||
// }
|
||||
|
||||
// // if the "EF" version invokes first, return that value
|
||||
// return results.FirstOrDefault(r => !r.Equals(default(T)));
|
||||
// }
|
||||
|
||||
// private static void LoadInstances()
|
||||
// {
|
||||
// if (dataAccessTypes == null)
|
||||
// {
|
||||
// var type = typeof(IDataAccess<T>);
|
||||
// var aggregateType = typeof(AggregateDataAccess<>);
|
||||
|
||||
// // load all types except for 1) the interface itself, 2) any interface, and 3) is not implementing AggregateDataAccess<T>
|
||||
// // NOTE: the "EF" version will load first, allowing for the "QuickBase" version to run last, in a separate thread if desired
|
||||
// dataAccessTypes = AppDomain.CurrentDomain
|
||||
// .GetAssemblies()
|
||||
// .Where(a => a.FullName.StartsWith("COA.EnterpriseServices.DataAccess"))
|
||||
// .SelectMany(a => a.ExportedTypes)
|
||||
// //.Where(t => type.IsAssignableFrom(t)/* && !t.IsInterface && !aggregateType.IsAssignableFrom(t)*/)
|
||||
// //.OrderBy(t => t.Name.StartsWith("QuickBase", StringComparison.OrdinalIgnoreCase))
|
||||
// .ToList();
|
||||
// }
|
||||
// }
|
||||
|
||||
// public bool Add(T item) => Invoke(d => d.Add(item));
|
||||
// public bool Update(T item) => Invoke(d => d.Update(item));
|
||||
// public ICollection<T> Get(int id) => Invoke(d => d.Get(id));
|
||||
// public ICollection<T> Get(Expression<Func<T, bool>> query) => Invoke(d => d.Get(query));
|
||||
//}
|
||||
}
|
||||
|
Reference in New Issue
Block a user