Linq Lookup使用多个条件

时间:2016-12-01 15:46:46

标签: c# linq

在我的程序中,只有在程序确定该项目尚未包含在集合中时才应创建项目。

这是我要阅读的代码。它不起作用,我无法弄清楚原因。

            foreach(var user in db.Gebruikers)
            {
                foreach(var parameter in db.ParametersWerkvorms)
                {
                    if(db.ZoekresultaatWerkvorms.Where(r => r.Werkvorm.Equals(parameter.Naam))) // ??????

// If user.username = db.ZoekresultaatWerkvorms.item.username && parameter.naam == db.ZoekresultaatWerkvorms.item.parameter{
                    var newItem = new ZoekResultaatParameter();
                    newItem.Parameter = parameter.Naam;
                    newItem.Opgezocht = 0;
                    newItem.Gebruikersnaam = user.Gebruikersnaam;
 // Write newItem to database
                }
            }
        }

1 个答案:

答案 0 :(得分:2)

class SearchPrintedChecksModel { public checkRuns = ko.observableArray<CheckRunModel>(null); public bankDrafts = ko.observableArray<BankDraftInfoModel>(null); public vendorChecks = ko.observableArray<BankDraftInfo>(null); public isSelectedCheck = ko.observable(false); public chosenChecks = ko.observableArray<BankDraftInfo>(null); public checkIDs = ko.observableArray(); public addCheck(checkIDs) { var checks = printModel.chosenChecks(); const CheckIDs = checkIDs; for (var i in checks) { checkIDs.push(checks[i].CheckID); ??? } } public selectAllChecks = ko.pureComputed({ read: function () { return this.chosenChecks().length === this.vendorChecks().length; }, write: function(value) { this.chosenChecks(value ? this.vendorChecks.slice(0) : []); const checks = printModel.chosenChecks(); const checkIDs = printModel.checkIDs(); for (let i in checks) { if (checks.hasOwnProperty(i)) { printModel.checkIDs.push(checks[i].CheckID); } } this.addCheck(checkIDs); }, owner: this }); } $(document).ready(() => { ko.applyBindings(printModel); }); 返回.Where,您需要IEnumerable<T>

尝试类似:bool