/// <summary> /// Updates survey /// </summary> /// <param name="queuedSurveyDto"></param> /// <returns></returns> public OperationResult <ISurveyDTO> UpdateSurvey(ISurveyDTO surveyDto) { OperationResult <ISurveyDTO> operationResult = null; try { ISurveyDAC surveyDac = (ISurveyDAC)DataAccessComponent.Create(DACType.Survey); ISurveyDTO resultDto = surveyDac.UpdateSurvey(surveyDto); operationResult = resultDto != null ? OperationResult <ISurveyDTO> .CreateSuccessResult(resultDto) : OperationResult <ISurveyDTO> .CreateFailureResult( ResourceUtility.GetCaptionFor( ResourceConstants.Survey.ErrorMessages.FailedToUpdateSurvey)); } catch (DACException dacEx) { operationResult = OperationResult <ISurveyDTO> .CreateErrorResult(dacEx.Message, dacEx.StackTrace); } catch (Exception ex) { ExceptionManager.HandleException(ex); operationResult = OperationResult <ISurveyDTO> .CreateErrorResult(ex.Message, ex.StackTrace); } return(operationResult); }
/// <summary> /// Creates an instance of a DatabaseEntity object that does not exist in the database. /// </summary> /// <param name="tableName">Used to identify with which table the instance is interacting.</param> public DatabaseEntity(string tableName, DataAccessComponent dbAccess = null) { ExistingRecord = false; Id = Guid.NewGuid(); TableName = tableName; EntityMembersAsOf = null; if (dbAccess == null) { DbAccess = Access.VspDbAccess; } else { DbAccess = dbAccess; } SqlCrud = new SqlCrudOperator(DbAccess, TableName); RegisteredColumns = new List <ColumnTuple>(); RegisterMembers(); }
/// <summary> /// Creates an instance of an existing DatabaseEntity object that does exist as a database record. /// </summary> /// <param name="tableName">Used to identify with which table the instance is interacting.</param> /// <param name="id">Used to identify with which record the instance is interacting.</param> public DatabaseEntity(string tableName, Guid id, DataAccessComponent dbAccess = null) { ExistingRecord = true; Id = id; TableName = tableName; if (dbAccess == null) { DbAccess = Access.VspDbAccess; } else { DbAccess = dbAccess; } SqlCrud = new SqlCrudOperator(DbAccess, TableName); RegisteredColumns = new List <ColumnTuple>(); RegisterMembers(); RefreshMembers(true); SetRegisteredMembers(); }
static void Main(string[] args) { var empList = new DataAccessComponent().GetEmployees(); var deptList = new DataAccessComponent().GetDeptartment(); //1. Select All Employee var result = from emp in empList select emp; //Extension Syntax result = empList.Select(o => o); //2. Select Where Department Id = 52 var result2 = from emp in empList where emp.Deptid == 52 select emp; //Extension method syntax result2 = empList.Where(o => o.Deptid == 52); //3. Select Only Few Columns var result3 = from emp in empList select new { emp.Ecode, emp.Ename }; //Extension Method //4. Select Computed Columns var result4 = from emp in empList select new { newCode = emp.Ecode, newName = emp.Ename, newSalary = emp.Salary, newDept = emp.Salary, bonus = emp.Salary * 0.1, }; //Extension Method //result4 = empList.Select (o => new { // o.Ecode, // o.Ename, // o.Salary, // o.Deptid, // bonus = o.Salary * 0.1, //}); //5. Order Records var result5 = from emp in empList orderby emp.Salary descending select emp; //6. Grouping Records var result6 = from emp in empList group emp by emp.Deptid into g select new { did = g.Key, }; //Display foreach (var item in result) { Console.WriteLine(item.Ecode + "\t" + item.Ename + "\t" + item.Deptid + "\t" + item.Salary); } Console.WriteLine(""); //Display foreach (var item in result2) { Console.WriteLine(item.Ecode + "\t" + item.Ename + "\t" + item.Deptid + "\t" + item.Salary); } Console.WriteLine(""); //Display foreach (var item in result3) { Console.WriteLine(item.Ecode + "\t" + item.Ename + "\t"); } Console.WriteLine(""); //Display foreach (var item in result4) { Console.WriteLine(item.newName + "\t" + item.newName + "\t" + item.newDept + "\t" + item.newSalary + "\t" + item.bonus); } //Joins var joinsResult = from emp in empList join dep in deptList on emp.Deptid equals dep.Deptid select new { emp.Ecode, emp.Ename, emp.Salary, emp.Deptid, dep.Dhead, dep.Dname }; //Extension Methods joinsResult = empList.Join(deptList, o => o.Deptid, i => i.Deptid, (o, i) => new { o.Ecode, o.Ename, o.Salary, o.Deptid, i.Dhead, i.Dname }); Console.WriteLine(""); Console.ReadLine(); }
public BusinessLayerComponent(string path) { this.Path = path; SplitHeader(); dataAccessComponent = new DataAccessComponent(path, dict); }