0

在我的 WPF Grid 上,我正在填充以下属性。最后两个来自另一张桌子。我想从另一个表中获取映射规则,其中sourceelementid事务表等于idmessagefield

public List<MessageFieldViewModel> GetAllViewModelMsgFields()
{
    messageFieldVModel = messageField.GetAllMessageField().Select(msgFields => new MessageFieldViewModel
    {
        Id = msgFields.Id,
        Code = msgFields.Code,
        Name = msgFields.Name,
        Position = msgFields.Position,
        Length = msgFields.Length,
        IsMapped = (transactionRuleList.Any(tr=> tr.SourceElementId ==msgFields.Id)),
        MappingRule = transactionRuleList.Where(mapRule => mapRule.MappingRule.Any(tr=> tr.SourceElementId ==msgFields.Id)),
    })
.ToList();
    return messageFieldVModel;
}

但映射规则列会引发错误。有人能帮我吗 ?

4

1 回答 1

0

这是一个解决方案:

      transactionRuleList = transationRuleViewModel.GetAllTranslationRules();
        messageFieldVModel = messageField.GetAllMessageField().Select(msgFields => new MessageFieldViewModel
        {
            Id = msgFields.Id,
            Code = msgFields.Code,
            Name = msgFields.Name,
            Position = msgFields.Position,
            Length = msgFields.Length,
            IsMapped = (transactionRuleList.Any(tr => tr.SourceElementId == msgFields.Id)),
            MappingRule = transactionRuleList.Any(mapRule => mapRule.SourceElementId == msgFields.Id)?transactionRuleList.First(mapRule => mapRule.SourceElementId == msgFields.Id).MappingRule:null
于 2013-06-06T17:57:33.320 回答