IQueryable-Vorgang in ASP.NET MVC

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: IQueryable-Vorgang in ASP.NET MVC

by Guest » 18 Jan 2025, 21:22

Ich bin neu bei IQueryable. Ich möchte alle Elemente in „selectedBus“ mit OR und alle Elemente in „depositi“ mit OR verketten.
Dann möchte ich, dass die beiden Prädikate (Prädikat und Prädikat 3) mit AND verknüpft sind Operator.

Code: Select all

var predicate = PredicateBuilder.False();
var predicate3 = PredicateBuilder.False();
var result = Context.tb_pulizie.AsQueryable();

if (selectedBus != null)
{
foreach (string keyword in selectedBus)
{
string temp = keyword;
predicate = predicate.Or(p => p.ID.Contains(temp));
}

result = Context.tb_pulizie.AsExpandable().Where(predicate);
// result = result.Where(predicate);
}

if (depositi != null)
{
foreach (string keyword in depositi)
{
string temp = keyword;
predicate3 = predicate3.Or(p => p.deposito.Contains(temp));
}

result = Context.tb_pulizie.AsExpandable().Where(predicate3);
}
Wie kann ich das tun?
Vielen Dank!

Top