Gio Mick Gio Mick - 1 year ago 68
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.

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download