mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 17:20:49 +08:00 
			
		
		
		
	- 修复 使用查询参数化功能时 ToList 子查询未传播参数列表的 bug;#462
This commit is contained in:
		@@ -532,5 +532,14 @@
 | 
				
			|||||||
            <param name="that"></param>
 | 
					            <param name="that"></param>
 | 
				
			||||||
            <returns></returns>
 | 
					            <returns></returns>
 | 
				
			||||||
        </member>
 | 
					        </member>
 | 
				
			||||||
 | 
					        <member name="M:Microsoft.Extensions.DependencyInjection.FreeSqlRepositoryDependencyInjection.AddFreeRepository(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{FreeSql.FluentDataFilter},System.Reflection.Assembly[])">
 | 
				
			||||||
 | 
					            <summary>
 | 
				
			||||||
 | 
					            批量注入 Repository,可以参考代码自行调整
 | 
				
			||||||
 | 
					            </summary>
 | 
				
			||||||
 | 
					            <param name="services"></param>
 | 
				
			||||||
 | 
					            <param name="globalDataFilter"></param>
 | 
				
			||||||
 | 
					            <param name="assemblies"></param>
 | 
				
			||||||
 | 
					            <returns></returns>
 | 
				
			||||||
 | 
					        </member>
 | 
				
			||||||
    </members>
 | 
					    </members>
 | 
				
			||||||
</doc>
 | 
					</doc>
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										60
									
								
								FreeSql.Tests/FreeSql.Tests/Issues/462.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								FreeSql.Tests/FreeSql.Tests/Issues/462.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,60 @@
 | 
				
			|||||||
 | 
					using FreeSql.DataAnnotations;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Diagnostics;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading;
 | 
				
			||||||
 | 
					using Xunit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace FreeSql.Tests.Issues
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class _462
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        [Fact]
 | 
				
			||||||
 | 
					        public void SelectTest()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            IFreeSql db = new FreeSql.FreeSqlBuilder()
 | 
				
			||||||
 | 
					                        .UseConnectionString(FreeSql.DataType.Oracle, "user id=1user;password=123456;data source=//127.0.0.1:1521/XE;Pooling=true;Max Pool Size=1")
 | 
				
			||||||
 | 
					                       .UseNameConvert(FreeSql.Internal.NameConvertType.ToUpper)
 | 
				
			||||||
 | 
					                       .UseGenerateCommandParameterWithLambda(true)
 | 
				
			||||||
 | 
					                       .UseAutoSyncStructure(true)
 | 
				
			||||||
 | 
					                        .UseMonitorCommand(cmd => Trace.WriteLine("\r\n线程" + Thread.CurrentThread.ManagedThreadId + ": " + cmd.CommandText))
 | 
				
			||||||
 | 
					                        .Build();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var startTime = DateTime.Now;
 | 
				
			||||||
 | 
					            var endTime = DateTime.Now;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var exp0 = 10;
 | 
				
			||||||
 | 
					            var cou = db.Select<V_HospitalReport>()
 | 
				
			||||||
 | 
					                .Where(a => a.ScheduledDttm.Date >= startTime.Date && a.ScheduledDttm.Date <= (endTime.AddDays(1)).Date)
 | 
				
			||||||
 | 
					                .ToList(a => new
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    subCount = db.Select<V_HOSPITALREPORT>().Where(b => b.SCHEDULED_DTTM == exp0).Count()
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Table(Name = "V_HospitalReport22")]
 | 
				
			||||||
 | 
					        public class V_HospitalReport
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            [Column(Name = "hospital_name")]
 | 
				
			||||||
 | 
					            public string HospitalName { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            [Column(Name = "dep")]
 | 
				
			||||||
 | 
					            public string Dep { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            [Column(Name = "instrna")]
 | 
				
			||||||
 | 
					            public string Instrna { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            [Column(Name = "confirm_doctor_name")]
 | 
				
			||||||
 | 
					            public string ConfirmDoctorName { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            [Column(Name = "Scheduled_Dttm")]
 | 
				
			||||||
 | 
					            public DateTime ScheduledDttm { get; set; }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        [Table(Name = "V_HOSPITALREPORT22111")]
 | 
				
			||||||
 | 
					        public class V_HOSPITALREPORT
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            public int SCHEDULED_DTTM { get; set; }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -30,7 +30,7 @@ namespace FreeSql.Internal
 | 
				
			|||||||
        internal const int ReadAnonymousFieldAsCsName = -53129;
 | 
					        internal const int ReadAnonymousFieldAsCsName = -53129;
 | 
				
			||||||
        public bool ReadAnonymousField(List<SelectTableInfo> _tables, StringBuilder field, ReadAnonymousTypeInfo parent, ref int index, Expression exp, Select0Provider select, SelectGroupingProvider grouping, List<LambdaExpression> whereCascadeExpression, List<string> findIncludeMany, bool isAllDtoMap)
 | 
					        public bool ReadAnonymousField(List<SelectTableInfo> _tables, StringBuilder field, ReadAnonymousTypeInfo parent, ref int index, Expression exp, Select0Provider select, SelectGroupingProvider grouping, List<LambdaExpression> whereCascadeExpression, List<string> findIncludeMany, bool isAllDtoMap)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Func<ExpTSC> getTSC = () => new ExpTSC { _tables = _tables, grouping = grouping, tbtype = SelectTableInfoType.From, isQuoteName = true, isDisableDiyParse = false, style = ExpressionStyle.Where, whereCascadeExpression = whereCascadeExpression };
 | 
					            Func<ExpTSC> getTSC = () => new ExpTSC { _tables = _tables, grouping = grouping, tbtype = SelectTableInfoType.From, isQuoteName = true, isDisableDiyParse = false, style = ExpressionStyle.Where, whereCascadeExpression = whereCascadeExpression, dbParams = select?._params }; //#462 添加 DbParams 解决
 | 
				
			||||||
            switch (exp.NodeType)
 | 
					            switch (exp.NodeType)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                case ExpressionType.Quote: return ReadAnonymousField(_tables, field, parent, ref index, (exp as UnaryExpression)?.Operand, select, grouping, whereCascadeExpression, findIncludeMany, isAllDtoMap);
 | 
					                case ExpressionType.Quote: return ReadAnonymousField(_tables, field, parent, ref index, (exp as UnaryExpression)?.Operand, select, grouping, whereCascadeExpression, findIncludeMany, isAllDtoMap);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user