public FreeSqlBuilder GetFreeSqlBuilder() { var freeSqlBuilder = new FreeSqlBuilder() .UseConnectionString(Options.FreeSqlGeneratorOptions.DatabaseType, Options.FreeSqlGeneratorOptions.ConnectionString); Options.FreeSqlDbContextOptions.EntityKey = Options.FreeSqlGeneratorOptions.ConnectionString; //基础配置 if (Options.FreeSqlGeneratorOptions.LazyLoading.HasValue) { freeSqlBuilder.UseGenerateCommandParameterWithLambda(Options.FreeSqlGeneratorOptions.LazyLoading.Value); } if (Options.FreeSqlGeneratorOptions.NoneCommandParameter.HasValue) { freeSqlBuilder.UseNoneCommandParameter(Options.FreeSqlGeneratorOptions.NoneCommandParameter.Value); } if (Options.FreeSqlGeneratorOptions.GenerateCommandParameterWithLambda.HasValue) { freeSqlBuilder.UseGenerateCommandParameterWithLambda(Options.FreeSqlGeneratorOptions.GenerateCommandParameterWithLambda.Value); } if (Options.FreeSqlGeneratorOptions.HandleCommandLog != null || Options.FreeSqlGeneratorOptions.MonitorCommandExecuting != null || Options.FreeSqlGeneratorOptions.MonitorCommandExecuted != null) { freeSqlBuilder.UseMonitorCommand( Options.FreeSqlGeneratorOptions.MonitorCommandExecuting ?? new Action <System.Data.Common.DbCommand>((cmd) => { }), Options.FreeSqlGeneratorOptions.MonitorCommandExecuted ?? new Action <System.Data.Common.DbCommand, string>((cmd, log) => { if (Options.FreeSqlGeneratorOptions.HandleCommandLog != null) { Options.FreeSqlGeneratorOptions.HandleCommandLog.Invoke(log); } })); } //开发配置 if (Options.FreeSqlDevOptions?.AutoSyncStructure.HasValue == true) { freeSqlBuilder.UseAutoSyncStructure(Options.FreeSqlDevOptions.AutoSyncStructure.Value); } if (Options.FreeSqlDevOptions?.SyncStructureNameConvert.HasValue == true) { freeSqlBuilder.UseNameConvert(Options.FreeSqlDevOptions.SyncStructureNameConvert.Value); } if (Options.FreeSqlDevOptions?.ConfigEntityFromDbFirst.HasValue == true) { freeSqlBuilder.UseConfigEntityFromDbFirst(Options.FreeSqlDevOptions.ConfigEntityFromDbFirst.Value); } Options.SetupBuilder?.Invoke(freeSqlBuilder); return(freeSqlBuilder); }