public virtual T Get(Func <T, bool> predicate) { T entity = null; AppLogger.logDebug(this.ToString(), string.Format("Begin getting entity of {0}.", typeof(T))); try { if (predicate != null) { entity = EntitiesSet.FirstOrDefault(predicate); if (entity != null) { AppLogger.logDebug(this.ToString(), string.Format("Entity of {0} found.", typeof(T))); AppLogger.logDebug(this.ToString(), "GET", entity); EntitiesSet.Detach(entity); } else { AppLogger.logDebug(this.ToString(), string.Format("Entity of {0} not found.", typeof(T))); } } } catch (Exception ex) { AppLogger.logError(this.ToString(), ex); throw; } AppLogger.logDebug(this.ToString(), string.Format("Finish getting entity of {0}.", typeof(T))); return(entity); }