Gio Mick Gio Mick - 3 months ago 6x
SQL Question

What is the meaning of the mentioned query?

If I had the table "CustomerDetails" than what is the below query explains??

var details = (from data in entity.CustomerDetails where (data.CustomerId == CustId && data.CustomerProjectID == CustProjId) select data).FirstOrDefault();

Share the exact meaning. Thanks in advance.


That query selects the data from the CustomerDetails table where the CustomerId equals the given CustId and the CustomerProjectID equals the given CustProjId. It then returns the first element from the set that returns.

I personally find it easier to use LINQ Expressions like so:

var details = entity.CustomerDetails
    .FirstOrDefault(cust => 
        cust.CustomerId == CustId && 
        cust.CustomerProjectID == CustProjId