Labels

Thursday, June 25, 2015

Querying the List of class objects using LINQ

public string GetExceptionMessage(Int16 messageID, List<ExceptionMessage> exMsg)
        {

            var exceptionMessage = (from em in exMsg
                                    where em.ExceptionMessageID == messageID
                                    select em.ExceptionMsg).FirstOrDefault();

            return string.IsNullOrWhiteSpace(exceptionMessage) ? string.Empty : exceptionMessage;
        }

No comments:

Post a Comment