public static EmployeeInformationEntities CreateContext() { var config = ServiceConfigurationLoader.Load(); var configuration = config.ConnectionStrings[typeof(EmployeeInformationEntities).Name]; var context = new EmployeeInformationEntities(ConnectionFactory.Create(configuration)); context.configuration = configuration; return(context); }
private Employee GetAuthenticatedUserInfo(string userID) { using (EmployeeInformationEntities context = EmployeeInformationEntities.CreateContext()) { FileSqlDefinitionFactory factory = new FileSqlDefinitionFactory("ServiceUnits/Actos/V1/"); DataQuery query = new DataQuery(context, factory, logContext).AppendQuery(sql); query.SetParameter("UserID", userID); Employee userInfo = query.GetList <Employee>().FirstOrDefault(); if (userInfo == null) { throw new InvalidOperationException(Resources.UserNotExist); } return(userInfo); } }