public static async Task <LineItemList> GetByOrderIdAsync(System.Int32 orderId) { var criteria = new LineItemCriteria { OrderId = orderId }; return(await DataPortal.FetchAsync <LineItemList>(criteria)); }
/// <summary> /// Returns a <see cref="LineItem"/> object of the specified criteria. /// </summary> /// <param name="orderId">No additional detail available.</param> /// <returns>A <see cref="LineItem"/> object of the specified criteria.</returns> internal static LineItem GetByOrderIdChild(System.Int32 orderId) { var criteria = new LineItemCriteria { OrderId = orderId }; return(DataPortal.FetchChild <LineItem>(criteria)); }
/// <summary> /// Returns a <see cref="LineItemList"/> object of the specified criteria. /// </summary> /// <param name="orderId">No additional detail available.</param> /// <param name="lineNum">No additional detail available.</param> /// <returns>A <see cref="LineItemList"/> object of the specified criteria.</returns> public static LineItemList GetByOrderIdLineNum(System.Int32 orderId, System.Int32 lineNum) { var criteria = new LineItemCriteria { OrderId = orderId, LineNum = lineNum }; return(DataPortal.Fetch <LineItemList>(criteria)); }
internal static async Task <LineItem> GetByOrderIdChildAsync(System.Int32 orderId) { var criteria = new LineItemCriteria { OrderId = orderId }; return(await DataPortal.FetchAsync <LineItem>(criteria)); }
/// <summary> /// Returns a <see cref="LineItem"/> object of the specified criteria. /// </summary> /// <param name="orderId">No additional detail available.</param> /// <param name="lineNum">No additional detail available.</param> /// <returns>A <see cref="LineItem"/> object of the specified criteria.</returns> internal static LineItem GetByOrderIdLineNumChild(System.Int32 orderId, System.Int32 lineNum) { var criteria = new LineItemCriteria { OrderId = orderId, LineNum = lineNum }; return(DataPortal.FetchChild <LineItem>(criteria)); }
public static async Task DeleteLineItemAsync(System.Int32 orderId, System.Int32 lineNum) { var criteria = new LineItemCriteria { OrderId = orderId, LineNum = lineNum }; await DataPortal.DeleteAsync <LineItem>(criteria); }
public static async Task <LineItem> GetByOrderIdLineNumAsync(System.Int32 orderId, System.Int32 lineNum) { var criteria = new LineItemCriteria { OrderId = orderId, LineNum = lineNum }; return(await DataPortal.FetchAsync <LineItem>(criteria)); }
/// <summary> /// Returns a <see cref="LineItem"/> object of the specified criteria. /// </summary> /// <param name="orderId">No additional detail available.</param> /// <returns>A <see cref="LineItem"/> object of the specified criteria.</returns> public static LineItem GetByOrderId(System.Int32 orderId) { var criteria = new LineItemCriteria { OrderId = orderId }; return(DataPortal.Fetch <LineItem>(criteria)); }
private void DataPortal_Fetch(LineItemCriteria criteria) { bool cancel = false; OnFetching(criteria, ref cancel); if (cancel) { return; } RaiseListChangedEvents = false; // Fetch Child objects. string commandText = String.Format("SELECT [OrderId], [LineNum], [ItemId], [Quantity], [UnitPrice] FROM [dbo].[LineItem] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag)); using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); using (var command = new SqlCommand(commandText, connection)) { command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag)); using (var reader = new SafeDataReader(command.ExecuteReader())) { if (reader.Read()) { do { this.Add(PetShop.Business.LineItem.GetLineItem(reader)); } while(reader.Read()); } } } } RaiseListChangedEvents = true; OnFetched(); }
private void Child_Fetch(LineItemCriteria criteria) { bool cancel = false; OnChildFetching(criteria, ref cancel); if (cancel) { return; } string commandText = String.Format("SELECT [OrderId], [LineNum], [ItemId], [Quantity], [UnitPrice] FROM [dbo].[LineItem] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag)); using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); using (var command = new SqlCommand(commandText, connection)) { command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag)); using (var reader = new SafeDataReader(command.ExecuteReader())) { if (reader.Read()) { Map(reader); } else { throw new Exception(String.Format("The record was not found in 'dbo.LineItem' using the following criteria: {0}.", criteria)); } } } } OnChildFetched(); MarkAsChild(); }
protected override void DataPortal_Update() { bool cancel = false; OnUpdating(ref cancel); if (cancel) { return; } if (OriginalOrderId != OrderId || OriginalLineNum != LineNum) { // Insert new child. LineItem item = new LineItem { OrderId = OrderId, LineNum = LineNum, ItemId = ItemId, Quantity = Quantity, UnitPrice = UnitPrice }; item = item.Save(); // Mark editable child lists as dirty. This code may need to be updated to one-to-one relationships. // Create a new connection. using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); FieldManager.UpdateChildren(this, connection); } // Delete the old. var criteria = new LineItemCriteria { OrderId = OriginalOrderId, LineNum = OriginalLineNum }; DataPortal_Delete(criteria); // Mark the original as the new one. OriginalOrderId = OrderId; OriginalLineNum = LineNum; OnUpdated(); return; } const string commandText = "UPDATE [dbo].[LineItem] SET [OrderId] = @p_OrderId, [LineNum] = @p_LineNum, [ItemId] = @p_ItemId, [Quantity] = @p_Quantity, [UnitPrice] = @p_UnitPrice WHERE [OrderId] = @p_OriginalOrderId AND [LineNum] = @p_OriginalLineNum; SELECT [OrderId], [LineNum] FROM [dbo].[LineItem] WHERE [OrderId] = @p_OriginalOrderId AND [LineNum] = @p_OriginalLineNum"; using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); using (var command = new SqlCommand(commandText, connection)) { command.Parameters.AddWithValue("@p_OriginalOrderId", this.OriginalOrderId); command.Parameters.AddWithValue("@p_OrderId", this.OrderId); command.Parameters.AddWithValue("@p_OriginalLineNum", this.OriginalLineNum); command.Parameters.AddWithValue("@p_LineNum", this.LineNum); command.Parameters.AddWithValue("@p_ItemId", this.ItemId); command.Parameters.AddWithValue("@p_Quantity", this.Quantity); command.Parameters.AddWithValue("@p_UnitPrice", this.UnitPrice); //result: The number of rows changed, inserted, or deleted. -1 for select statements; 0 if no rows were affected, or the statement failed. int result = command.ExecuteNonQuery(); if (result == 0) { throw new DBConcurrencyException("The entity is out of date on the client. Please update the entity and try again. This could also be thrown if the sql statement failed to execute."); } LoadProperty(_originalOrderIdProperty, this.OrderId); LoadProperty(_originalLineNumProperty, this.LineNum); } FieldManager.UpdateChildren(this, connection); } OnUpdated(); }
/// <summary> /// Determines if a record exists in the LineItem table in the database for the specified criteria. /// </summary> public static async Task <bool> ExistsAsync(LineItemCriteria criteria) { return(await PetShop.Business.ExistsCommand.ExecuteAsync(criteria)); }
/// <summary> /// Determines if a record exists in the LineItem table in the database for the specified criteria. /// </summary> /// <param name="criteria">The criteria parameter is an <see cref="LineItem"/> object.</param> /// <returns>A boolean value of true is returned if a record is found.</returns> public static bool Exists(LineItemCriteria criteria) { return(PetShop.Business.ExistsCommand.Execute(criteria)); }
/// <summary> /// CodeSmith generated stub method that is called when fetching the child <see cref="LineItem"/> object. /// </summary> /// <param name="criteria"><see cref="LineItemCriteria"/> object containing the criteria of the object to fetch.</param> /// <param name="cancel">Value returned from the method indicating whether the object fetching should proceed.</param> partial void OnChildFetching(LineItemCriteria criteria, ref bool cancel);
/// <summary> /// CodeSmith generated stub method that is called when deleting the <see cref="LineItem"/> object. /// </summary> /// <param name="criteria"><see cref="LineItemCriteria"/> object containing the criteria of the object to delete.</param> /// <param name="cancel">Value returned from the method indicating whether the object deletion should proceed.</param> partial void OnDeleting(LineItemCriteria criteria, ref bool cancel);
public static LineItemList GetByCriteria(LineItemCriteria criteria) { return(DataPortal.Fetch <LineItemList>(criteria)); }
/// <summary> /// Determines if a record exists in the LineItem in the database for the specified criteria. /// </summary> /// <param name="criteria">The criteria parameter is a <see cref="LineItemList"/> object.</param> /// <returns>A boolean value of true is returned if a record is found.</returns> public static bool Exists(LineItemCriteria criteria) { return(PetShop.Business.LineItem.Exists(criteria)); }
public static async Task <LineItemList> GetByCriteriaAsync(LineItemCriteria criteria) { return(await DataPortal.FetchAsync <LineItemList>(criteria)); }