linq2db与Entity Framework Core的集成以及dbContext.GetCte丢失。

huangapple go评论97阅读模式
英文:

linq2db integration with Entity Framework Core and dbContext.GetCte missing

问题

linq2db有与EF Core上下文集成的可能性:

EF Core集成

> 在您的代码中,您需要使用以下调用来初始化集成:
> LinqToDBForEFTools.Initialize();

但在这行之后,EF Core上下文中没有GetCte方法。

  1. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  2. {
  3. optionsBuilder.UseSqlServer("Server=.; Database=dbName;User Id=sa; Password=ble; encrypt=false", options => options.CommandTimeout(10))
  4. .LogTo(Console.WriteLine, new[] { DbLoggerCategory.Query.Name, DbLoggerCategory.Database.Connection.Name, DbLoggerCategory.Database.Name }
  5. );
  6. // .UseQueryTrackingBehavior( QueryTrackingBehavior.NoTracking);
  7. LinqToDBForEFTools.Initialize();
  8. }

使用

  1. using (var _dbContext = new CompanyContext())
  2. {
  3. _dbContext.GetCte - 找不到
  4. _dbContext.BulkCopy - 找到
  5. }

是否可以在EF Core上下文中使用GetCte,还是必须进行完整的linq2db配置才能使用递归CTE?

英文:

linq2db has possibility to "integrate" with EF Core context:

EF Core integration

> In your code you need to initialize integration using following call:
> LinqToDBForEFTools.Initialize();

but after only that line there is no method GetCte in EF Core context.

  1. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  2. {
  3. optionsBuilder.UseSqlServer("Server=.; Database=dbName;User Id=sa; Password=ble; encrypt=false", options => options.CommandTimeout(10))
  4. .LogTo(Console.WriteLine, new[] { DbLoggerCategory.Query.Name, DbLoggerCategory.Database.Connection.Name, DbLoggerCategory.Database.Name }
  5. );
  6. // .UseQueryTrackingBehavior( QueryTrackingBehavior.NoTracking);
  7. LinqToDBForEFTools.Initialize();
  8. }

USING

  1. using (var _dbContext = new CompanyContext())
  2. {
  3. _dbContext.GetCte - not found
  4. _dbContext.BulkCopy - found
  5. }

Is it possible to use GetCte with EF Core DbContext or linq2db full configuration should be done to have a possibility to use recursive CTE?

答案1

得分: 2

"seems to work" 意思是 "似乎工作正常"。

英文:

seems to work

  1. using (var _dbContext = new CompanyContext())
  2. {
  3. using (var db = _dbContext.CreateLinqToDBConnection())
  4. {
  5. }
  6. }

huangapple
  • 本文由 发表于 2023年8月5日 01:04:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76837917.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定