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

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

linq2db integration with Entity Framework Core and dbContext.GetCte missing

问题

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

EF Core集成

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

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

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

使用

using (var _dbContext = new CompanyContext())
{
	_dbContext.GetCte - 找不到
	_dbContext.BulkCopy - 找到
}

是否可以在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.

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

USING

using (var _dbContext = new CompanyContext())
{
	_dbContext.GetCte - not found
	_dbContext.BulkCopy - found
}

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

using (var _dbContext = new CompanyContext())
{
	using (var db = _dbContext.CreateLinqToDBConnection())
	{

	}
}

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:

确定