If entity exists return a value in Entity Framework

I have Two tables "Customer" table and "Blacklist" customer table. When i blacklist a customer i put the customerid as a foreign key to Blacklist table.

What i want to do is I need to find the Customer by "CusId" in the Customer Table. I retrieve Name,Area,Telephone,Email from Customer table. When i retrive it, it should also check whether the customer id is in the black list customer table too. depending on the existance it should pass a boolean value.

Final result should have total 5 columns. (Name,Area,Telephone,Email,IsBlacklist).

Please help me to code this Entity Framework C#. Thanks in advance.




you can use navigation property of blacklist, that is exist on customer :

var customer = Customer.Select(u => new
    Blacklist = u.Blacklist.Any()

To start you off:

var customer =
    from c in Customer
    where c.CusId == yourId
    select new 
        c.Name, c.Area, c.Telephone, c.Email, 
        IsBlacklist = Blacklist.Any(b => b.CusId == yourId)

Need Your Help

Injecting JS functions into the page from a Greasemonkey script on Chrome

javascript google-chrome google-chrome-extension greasemonkey userscripts

I have a Greasemonkey script that works just fine in Firefox and Opera. I struggle with getting it to work in Chrome, however. The problem is injecting a function into the page that can be invoked by