Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple assembly updates; ModelHelper ef model types dynamically imported and ActionMapper full AppDomain scan. #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions SapphireDb/Helper/ModelHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using Newtonsoft.Json.Linq;
Expand Down Expand Up @@ -239,8 +240,9 @@ public static object SetFields(this Type entityType, object newValues)

public static IQueryable<object> GetValues(this SapphireDbContext db, KeyValuePair<Type, string> property)
{
IQueryable<object> values = (IQueryable<object>) db.GetType().GetProperty(property.Value)?.GetValue(db);
return values?.AsNoTracking();
MethodInfo method = db.GetType().GetMethod((string)"Set", (int)(BindingFlags.Public | BindingFlags.Instance), Type.EmptyTypes);
method = method.MakeGenericMethod(property.Key);
return ((IQueryable<object>)method.Invoke(db, null))?.AsNoTracking();
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion SapphireDb/Internal/ActionMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ActionMapper

public ActionMapper()
{
actionHandlerTypes = Assembly.GetEntryAssembly()?.GetTypes()
actionHandlerTypes = (AppDomain.CurrentDomain.GetAssemblies().ToArray().SelectMany(x => x.GetTypes()))
.Where(t => typeof(ActionHandlerBase).IsAssignableFrom(t) && t.Name.EndsWith("Actions"))
.ToDictionary(t => t.Name.Substring(0, t.Name.LastIndexOf("Actions", StringComparison.Ordinal)).ToCamelCase(), t => t);

Expand Down