Skip to content
Merged
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
41 changes: 41 additions & 0 deletions NorthwindCRUD/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/NorthwindCRUD.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/NorthwindCRUD.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/NorthwindCRUD.sln"
],
"problemMatcher": "$msCompile"
}
]
}
24 changes: 24 additions & 0 deletions NorthwindCRUD/NorthwindCRUD.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.2.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NorthwindCRUD", "NorthwindCRUD.csproj", "{A0D23213-EEA1-7104-1A67-9ED52FDE887F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A0D23213-EEA1-7104-1A67-9ED52FDE887F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A0D23213-EEA1-7104-1A67-9ED52FDE887F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A0D23213-EEA1-7104-1A67-9ED52FDE887F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A0D23213-EEA1-7104-1A67-9ED52FDE887F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BB60B76A-7CB6-43CA-948B-625C7A90366C}
EndGlobalSection
EndGlobal
8 changes: 4 additions & 4 deletions NorthwindCRUD/QueryBuilder/QueryExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ private static Expression BuildInExpression(DataContext db, Query? query, Member

private static Expression BuildInExpression<T>(DataContext db, Query? query, MemberExpression field)
{
var d = RunSubquery(db, query).Select(x => (T)ProjectField(x, query?.ReturnFields[0] ?? string.Empty)).ToArray();
var d = RunSubquery(db, query).Select(x => (T)ProjectField(x, query?.ReturnFields[0] ?? string.Empty)).Distinct();
var m = typeof(Enumerable).GetMethods()
.FirstOrDefault(method => method.Name == nameof(Enumerable.Contains) && method.GetParameters().Length == 2)
?.MakeGenericMethod(typeof(T)) ?? throw new InvalidOperationException("Missing method");
Expand Down Expand Up @@ -244,10 +244,10 @@ private static IEnumerable<dynamic> RunSubquery(DataContext db, Query? query)
};
}

private static dynamic? ProjectField(dynamic? obj, string field)
private static dynamic? ProjectField(object? obj, string field)
{
var property = obj?.GetType().GetProperty(field, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance) ?? throw new InvalidOperationException($"Property '{field}' not found on type '{obj?.GetType()}'");
return property?.GetValue(obj);
var property = obj?.GetType().GetMember(field, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance)?.FirstOrDefault() ?? throw new InvalidOperationException($"Property '{field}' not found on type '{obj?.GetType()}'");
return property.GetMemberValue(obj);
}

private static Expression GetSearchValue(dynamic? value, Type targetType)
Expand Down