mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 17:20:49 +08:00 
			
		
		
		
	- 修复 OledbOracle 参数化处理 bug;
This commit is contained in:
		@@ -646,10 +646,11 @@ namespace base_entity
 | 
			
		||||
				.ToSql();
 | 
			
		||||
 | 
			
		||||
			var astsql03 = fsql.Select<AsTableLog>()
 | 
			
		||||
				.Where(a => a.createtime < DateTime.Parse("2023-5-1"))
 | 
			
		||||
                .FromQuery(fsql.Select<AsTableLogExt>())
 | 
			
		||||
				.InnerJoin((a, b) => a.id == b.id)
 | 
			
		||||
				.OrderBy((a, b) => a.createtime)
 | 
			
		||||
	            .Where(a => a.createtime.Between(DateTime.Parse("2022-3-1"), DateTime.Parse("2023-5-1")))
 | 
			
		||||
                .WithTempQuery(a => a)
 | 
			
		||||
				.FromQuery(fsql.Select<AsTableLogExt>().Where(a => a.createtime.Between(DateTime.Parse("2022-3-1"), DateTime.Parse("2023-5-1"))))
 | 
			
		||||
	            .InnerJoin((a, b) => a.id == b.id)
 | 
			
		||||
	            .OrderBy((a, b) => a.createtime)
 | 
			
		||||
				.ToSql();
 | 
			
		||||
 | 
			
		||||
			var astsql04 = fsql.Select<AsTableLog, AsTableLogExt>()
 | 
			
		||||
 
 | 
			
		||||
@@ -733,6 +733,15 @@
 | 
			
		||||
            <param name="modelBuilder"></param>
 | 
			
		||||
            <returns></returns>
 | 
			
		||||
        </member>
 | 
			
		||||
        <member name="M:FreeSqlDbContextExtensions.ApplyConfigurationsFromAssembly(FreeSql.ICodeFirst,System.Reflection.Assembly,System.Func{System.Type,System.Boolean})">
 | 
			
		||||
            <summary>
 | 
			
		||||
            根据Assembly扫描所有继承IEntityTypeConfiguration<T>的配置类
 | 
			
		||||
            </summary>
 | 
			
		||||
            <param name="codeFirst"></param>
 | 
			
		||||
            <param name="assembly"></param>
 | 
			
		||||
            <param name="predicate"></param>
 | 
			
		||||
            <returns></returns>
 | 
			
		||||
        </member>
 | 
			
		||||
        <member name="M:FreeSqlDbContextExtensions.CreateDbContext(IFreeSql)">
 | 
			
		||||
            <summary>
 | 
			
		||||
            创建普通数据上下文档对象
 | 
			
		||||
@@ -791,5 +800,14 @@
 | 
			
		||||
            <param name="that"></param>
 | 
			
		||||
            <returns></returns>
 | 
			
		||||
        </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>
 | 
			
		||||
</doc>
 | 
			
		||||
 
 | 
			
		||||
@@ -720,10 +720,16 @@ WHERE (((a.""NAME"") in (SELECT s.""TITLE"" as1
 | 
			
		||||
        }
 | 
			
		||||
        [Fact]
 | 
			
		||||
        public void WhereIf()
 | 
			
		||||
        {
 | 
			
		||||
            //<2F><><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>a.Type<70><65>a.Type.Parent <20><><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
			
		||||
            var query = select.WhereIf(true, a => a.Id == 10);
 | 
			
		||||
		{
 | 
			
		||||
            var time = DateTime.Parse("2023-12-12");
 | 
			
		||||
            var query = select.Where(x => x.CreateTime == time);
 | 
			
		||||
            var sql = query.ToSql().Replace("\r\n", "");
 | 
			
		||||
			Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a WHERE (a.\"CREATETIME\" = to_timestamp('2023-12-12 00:00:00.000000','YYYY-MM-DD HH24:MI:SS.FF6'))", sql);
 | 
			
		||||
			query.ToList();
 | 
			
		||||
 | 
			
		||||
			//<2F><><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>a.Type<70><65>a.Type.Parent <20><><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
			
		||||
			query = select.WhereIf(true, a => a.Id == 10);
 | 
			
		||||
            sql = query.ToSql().Replace("\r\n", "");
 | 
			
		||||
            Assert.Equal("SELECT a.\"ID\", a.\"CLICKS\", a.\"TYPEGUID\", a.\"TITLE\", a.\"CREATETIME\" FROM \"TB_TOPIC22\" a WHERE (a.\"ID\" = 10)", sql);
 | 
			
		||||
            query.ToList();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,18 +1,17 @@
 | 
			
		||||
using FreeSql.Internal.CommonProvider;
 | 
			
		||||
using FreeSql.Oracle.Curd;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Data.Common;
 | 
			
		||||
using System.Text.RegularExpressions;
 | 
			
		||||
using System.Collections.Concurrent;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
using System.IO;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Data.Common;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Reflection;
 | 
			
		||||
using System.Text.RegularExpressions;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
 | 
			
		||||
namespace FreeSql.Oracle
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    public class OracleProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
 | 
			
		||||
	public class OracleProvider<TMark> : BaseDbProvider, IFreeSql<TMark>
 | 
			
		||||
    {
 | 
			
		||||
        public override ISelect<T1> CreateSelectProvider<T1>(object dywhere) => new OracleSelect<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere);
 | 
			
		||||
        public override IInsert<T1> CreateInsertProvider<T1>() => new OracleInsert<T1>(this, this.InternalCommonUtils, this.InternalCommonExpression);
 | 
			
		||||
@@ -44,7 +43,23 @@ namespace FreeSql.Oracle
 | 
			
		||||
            this.Aop.CommandBefore += (_, e) =>
 | 
			
		||||
            {
 | 
			
		||||
                if (e.Command.Parameters.Count > 0)
 | 
			
		||||
                    e.Command.CommandText = _regCommandText.Replace(e.Command.CommandText, "?");
 | 
			
		||||
                {
 | 
			
		||||
                    var dbparms = new DbParameter[e.Command.Parameters.Count];
 | 
			
		||||
                    e.Command.Parameters.CopyTo(dbparms, 0);
 | 
			
		||||
                    var cmdText = e.Command.CommandText;
 | 
			
		||||
                    var ischanged = false;
 | 
			
		||||
                    foreach(var dbparm in dbparms.OrderByDescending(a => a.ParameterName.Length))
 | 
			
		||||
                    {
 | 
			
		||||
                        if (dbparm.ParameterName[0] != ':') continue;
 | 
			
		||||
                        var idx = cmdText.IndexOf(dbparm.ParameterName);
 | 
			
		||||
                        if (idx != -1)
 | 
			
		||||
                        {
 | 
			
		||||
                            ischanged = true;
 | 
			
		||||
							cmdText = $"{cmdText.Substring(0, idx)}?{cmdText.Substring(idx + dbparm.ParameterName.Length)}";
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    if (ischanged) e.Command.CommandText = cmdText;
 | 
			
		||||
                }
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            this.Aop.AuditDataReader += (_, e) =>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user