C# Lambda Problem -


Maybe something simple, but as I'm new to Lambda, the problem is to avoid me:

  M = & gt; M.contactID == Contact ID & amp; Amp; M.primaryAddress == True & amp; Amp; (M.addressTypeID == 2 || m.addressTypeID == 3)  

I tried to use that Lambda expression but I found an invalid operator.

Edit:

The concurrent SQL query will be:

  SELECT * contacts WHERE contactID = 3 and primaryAddress = 1 and (addressTypeID = 2 or addressTypeID = 3)  

I have a repository function defined like this:

  Public e Single (expression & lt; Funk & lt; E, bool & gt; & gt; where) {Back to ObjectSet. Single & lt; E & gt; (where); }  

I am passing the lambda expression above this function:

  myRepository.Single (m => m.contactID == contactID & Amp; Amp; m.primaryAddress == True & amp; amp; amp; amp; amp; (m.addressTypeID == 2 || m.addressTypeID == 3));  

If you get a invalid operation exception The most likely reason is that there are more than one record that matches your criteria.

Invalid Operation Exposure will increase if any value is greater than the right value. In this situation, try using instead:

  myRepository.First (m => m.contactID == contactID & amp; amp; m.primaryAddress == true & Amp; amp; (m.addressTypeID == 2 || M.Adracepid == 3);  

This will return matching results first, if more than one. If you do not need to handle any matches, then check (whoever returns zero if there are no matches).


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -