Thanks to visit codestin.com
Credit goes to github.com

Skip to content

方法SelectAllPayIfConfigListByAppIdAsync报错 #11

@damaozou

Description

@damaozou

Image

这里报错。

错误提示:系统异常This MySqlConnection is already in use. See https://fl.vu/mysql-conn-reuse

我理解的错误原因是接口对应的方法SelectAllPayIfConfigListByAppIdAsync返回的是IEnumerable。
程序立即return,知道迭代时才执行Select里面的代码。造成数据库连接已被释放。

        var result = defineList.AsEnumerable().Select(define =>
        {
            var entity = _mapper.Map<PayInterfaceDefineDto>(define);
            entity.AddExt("mchType", mchInfo.Type);// 所属商户类型
            entity.AddExt("ifConfigState", configList.Any(a => a.IfCode.Equals(define.IfCode) && a.State.Equals(CS.YES)) ? CS.YES : null);
            entity.AddExt("subMchIsvConfig", mchInfo.Type == CS.MCH_TYPE_ISVSUB && !isvPayConfigMap.TryGetValue(define.IfCode, out _) ? CS.NO : null);
            return entity;
        });

但为什么会提示MySqlConnection is already in use????
希望能得到回复。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions