/// <summary> /// Gets all <see cref="IOrderStatus"/>. /// </summary> /// <param name="keys"> /// The keys. /// </param> /// <returns> /// The <see cref="IEnumerable{IOrderStatus}"/>. /// </returns> protected override IEnumerable <IOrderStatus> PerformGetAll(params Guid[] keys) { var dtos = new List <OrderStatusDto>(); if (keys.Any()) { // This is to get around the WhereIn max limit of 2100 parameters and to help with performance of each WhereIn query var keyLists = keys.Split(400).ToList(); // Loop the split keys and get them foreach (var keyList in keyLists) { dtos.AddRange(Database.Fetch <OrderStatusDto>(GetBaseQuery(false).WhereIn <OrderStatusDto>(x => x.Key, keyList, SqlSyntax))); } } else { dtos = Database.Fetch <OrderStatusDto>(GetBaseQuery(false)); } var factory = new OrderStatusFactory(); foreach (var dto in dtos) { yield return(factory.BuildEntity(dto)); } }
void Worker_DoWork(object sender, DoWorkEventArgs e) { List <Contact> contactlist = new ContactFactory().SelectAll(); // 3 = 'Project Manager' List <Employee> emplist = new EmployeeFactory().SelectByDesignation(5); List <OrderStatus> orderStatuslist = new OrderStatusFactory().SelectAll(); this.Dispatcher.Invoke(() => { CustomerComboBox.ItemsSource = contactlist; CustomerComboBox.DisplayMemberPath = "CompanyName"; CustomerComboBox.SelectedValuePath = "ID"; PanelComboBox.ItemsSource = panelList; PanelComboBox.DisplayMemberPath = "SerialNo"; PanelComboBox.SelectedValuePath = "ID"; AssignedEmployeeComboBox.ItemsSource = emplist; AssignedEmployeeComboBox.DisplayMemberPath = "FirstName"; AssignedEmployeeComboBox.SelectedValuePath = "ID"; OrderStatusComboBox.ItemsSource = orderStatuslist; OrderStatusComboBox.DisplayMemberPath = "Name"; OrderStatusComboBox.SelectedValuePath = "ID"; }); }
/// <summary> /// Updates an existing item in the database. /// </summary> /// <param name="entity"> /// The entity. /// </param> protected override void PersistUpdatedItem(IOrderStatus entity) { ((Entity)entity).UpdatingEntity(); var factory = new OrderStatusFactory(); var dto = factory.BuildDto(entity); Database.Update(dto); entity.ResetDirtyProperties(); }
/// <summary> /// Saves a new item to the database. /// </summary> /// <param name="entity"> /// The entity. /// </param> protected override void PersistNewItem(IOrderStatus entity) { ((Entity)entity).AddingEntity(); var factory = new OrderStatusFactory(); var dto = factory.BuildDto(entity); Database.Insert(dto); entity.Key = dto.Key; entity.ResetDirtyProperties(); }
void Worker_DoWork(object sender, DoWorkEventArgs e) { projlist = new ProjectFactory().SelectAll(); var orderStatusList = new OrderStatusFactory().SelectAll(); this.Dispatcher.Invoke(() => { SelectProjectComboBox.ItemsSource = projlist; SelectProjectComboBox.DisplayMemberPath = "Name"; SelectProjectComboBox.SelectedValuePath = "ID"; OrderStatusComboBox.ItemsSource = orderStatusList; OrderStatusComboBox.DisplayMemberPath = "Name"; OrderStatusComboBox.SelectedValuePath = "ID"; }); }
/// <summary> /// Gets a <see cref="IOrderStatus"/> by it's unique key. /// </summary> /// <param name="key"> /// The key. /// </param> /// <returns> /// The <see cref="IOrderStatus"/>. /// </returns> protected override IOrderStatus PerformGet(Guid key) { var sql = GetBaseQuery(false) .Where(GetBaseWhereClause(), new { Key = key }); var dto = Database.Fetch <OrderStatusDto>(sql).FirstOrDefault(); if (dto == null) { return(null); } var factory = new OrderStatusFactory(); var orderStatus = factory.BuildEntity(dto); return(orderStatus); }
/// <summary> /// Gets all <see cref="IOrderStatus"/>. /// </summary> /// <param name="keys"> /// The keys. /// </param> /// <returns> /// The <see cref="IEnumerable{IOrderStatus}"/>. /// </returns> protected override IEnumerable <IOrderStatus> PerformGetAll(params Guid[] keys) { if (keys.Any()) { foreach (var id in keys) { yield return(Get(id)); } } else { var factory = new OrderStatusFactory(); var dtos = Database.Fetch <OrderStatusDto>(GetBaseQuery(false)); foreach (var dto in dtos) { yield return(factory.BuildEntity(dto)); } } }