ASP.NET check if LinqToEntities returned something or not.

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2010-04-08T20:00:26Z Indexed on 2010/04/08 20:03 UTC
Read the original article Hit count: 151

Filed under:
|

How to make this method return boolean value, depending on query return. False - nothing, True - data exists. Before i just returned int from uniqueQuote.Count() but does not look like great method. Thank you!

private bool CheckEnquiryUser(int enquiryId, Guid userId)
            {
                int selectedEnquiryId = enquiryId;
                Guid currentUserId = userId;
                Entities ctx3 = new Entities();
                var uniqueQuote = from quot in ctx3.Enquiries.Include("aspnet_Users")
                                  where quot.EnquiryId == selectedEnquiryId &&
                                  quot.aspnet_Users.UserId == currentUserId

                              select quot;

            bool exist = uniqueQuote;
            return exist;

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about entity-framework