From 458fb57e80a14af13df3379873a02c717f8340d7 Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Sun, 13 Oct 2024 14:31:23 +0200 Subject: [PATCH] Add examples to test issue 837 --- .../ConsoleApp_net6.0.csproj | 1 + src-console/ConsoleApp_net6.0/Issue837.cs | 128 ++++++++++++++++++ src-console/ConsoleApp_net6.0/Program.cs | 3 + 3 files changed, 132 insertions(+) create mode 100644 src-console/ConsoleApp_net6.0/Issue837.cs diff --git a/src-console/ConsoleApp_net6.0/ConsoleApp_net6.0.csproj b/src-console/ConsoleApp_net6.0/ConsoleApp_net6.0.csproj index 84ca9532f..15f541738 100644 --- a/src-console/ConsoleApp_net6.0/ConsoleApp_net6.0.csproj +++ b/src-console/ConsoleApp_net6.0/ConsoleApp_net6.0.csproj @@ -5,6 +5,7 @@ net6.0 ConsoleApp_net6._0 enable + latest diff --git a/src-console/ConsoleApp_net6.0/Issue837.cs b/src-console/ConsoleApp_net6.0/Issue837.cs new file mode 100644 index 000000000..506ab775b --- /dev/null +++ b/src-console/ConsoleApp_net6.0/Issue837.cs @@ -0,0 +1,128 @@ +using System; +using System.Collections.Generic; +using System.Linq.Dynamic.Core; + +namespace ConsoleApp_net6._0 +{ + public static class Issue837 + { + public static void Test() + { + var selectExp = + """ + new { + ExpertPoints.Select( + new + { + Expert.Name, + BatchId, + ProjectSampleId, + ExpertId, + Opinion, + Result, + AttachmentValue, + CreateTime, + UpdateTime, + Deleted, + Id + }) AS Experts, + + Project.BatchId AS BatchId, + Project AS Project, + Id, + Result, + Opinion, + CreateTime, + UpdateTime, + Deleted + } + """; + + var result = DynamicExpressionParser.ParseLambda + ( + new ParsingConfig + { + ResolveTypesBySimpleName = true, + }, + true, + selectExp + ); + + Console.WriteLine(result); + } + } + + public class Project + { + public string BatchId { get; set; } = string.Empty; + } + + public class User + { + public long Id { get; set; } + + public string Name { get; set; } = string.Empty; + } + + public class ProjectSample + { + public string Id { get; set; } = string.Empty; + + public virtual Project? Project { get; set; } + + public int? Result { get; set; } + + public string? Opinion { get; set; } + + public virtual List? ExpertPoints { get; set; } + } + + public class ProjectSampleExpertPoint + { + public string Id { get; set; } = string.Empty; + + public string? BatchId { get; set; } + + public string? ProjectSampleId { get; set; } + + public virtual ProjectSample? ProjectSample { get; set; } + + public string? ExpertId { get; set; } + + public virtual User? Expert { get; set; } + + public string? Opinion { get; set; } + + public int? Result { get; set; } + + public string? AttachmentValue { get; set; } + + public DateTime CreateTime { get; set; } + + public DateTime UpdateTime { get; set; } + + public bool Deleted { get; set; } + } + + public class VProjectSample : ProjectSample + { + public string? BatchId { get; set; } + + public new Project? Project { get; set; } + + public string? OrganizationName { get; set; } + + public string? OrganizationTel { get; set; } + } + + public class VProjectSamplePoint : VProjectSample + { + public List? Experts { get; set; } + + // public string? ExpertName { get; set; } // Added + } + + public class VProjectSampleExpertPoint : ProjectSampleExpertPoint + { + } +} diff --git a/src-console/ConsoleApp_net6.0/Program.cs b/src-console/ConsoleApp_net6.0/Program.cs index 15323cc92..527181c4d 100644 --- a/src-console/ConsoleApp_net6.0/Program.cs +++ b/src-console/ConsoleApp_net6.0/Program.cs @@ -21,6 +21,9 @@ class Program { static void Main(string[] args) { + Issue837.Test(); + return; + Issue389DoesNotWork(); return; Issue389_Works();