在“each”中,当运行“FirstOrDefault”时会报错“已经有一个与此连接关联的打开的DataReader,必须先关闭它。”。怎么做 ?
public int SetUser(string[] dIds, string pId)
{
using (var scope = _dbContextScopeFactory.Create())
{
var db = scope.DbContexts.Get<JuCheapContext>();
var users = db.Users;
var user = users.FirstOrDefault(m => m.Id == pId);
if (user.Places == null)
{
user.Places = new List<PlaceEntity>();
}
var place = db.Place.Include(m => m.User).Where(m => dIds.Contains(m.Id));
place.Each(m =>
{
user.Places.Add(m);
//There is already an open DataReader associated with this Connection which must be closed first.
var pu = users.FirstOrDefault(u => u.LoginName == m.Key);
if (pu != null) …Run Code Online (Sandbox Code Playgroud) 标头"Abp.TenantId"是null因为".".
如果去掉"."(如"AbpTenantId"),就可以了。
如何添加带有 的标题"."?
=================================================== =====
localhost调试:
localhost没问题。
服务器中的相同代码,但服务器错误。
的代码tenantId:
日志没有tenantId,所以报错:
localhost没问题:
服务器失败: