Greg
Greg

Reputation:

C# Query an entity by using multiple parameters

What am I doing wrong. I get an error that says sequence has no arguements.

PumpSUM.tblcards card = ps.tblcards.First(p => (p.PinId == 1223 && p.CardId == 321));

Upvotes: 2

Views: 950

Answers (2)

João Silva
João Silva

Reputation: 91349

Use Take(1) or FirstOrDefault instead.

Upvotes: 0

Beatles1692
Beatles1692

Reputation: 5330

It seems that this problem occurs when there is no first element to choose.You'd better use FirstOrDefault function.

Upvotes: 3

Related Questions