This is a migrated thread and some comments may be shown as answers.

Filter entities when using OpenAccessDataSource

1 Answer 84 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Patrick Saunders
Top achievements
Rank 1
Patrick Saunders asked on 10 Jul 2012, 11:18 AM
I have read through the doco on using OpenAccessDataSource with reporting. My preview of my report is working fine, so its getting data from the model OK. Though the doco is very short on how to initialise the report with the ORM objects/apply filtering.

To me the examples in the help seem very contrived as they show the OADS controls as being external to the report, when in fact they are a member inside the report, meaning the cannot be initalised externaly as shown in the examples.

In my case, I have two OADS objects in my report, one for the order, one for the orderItems.

How should I set parameters so that the OADS control gets the correct data for the report.
In my case, I just want to set massOrderId externally.

Hopefully I'm missing something very basic.

Thanks,

Pat.

1 Answer, 1 is accepted

Sort by
0
Patrick Saunders
Top achievements
Rank 1
answered on 11 Jul 2012, 05:22 AM
For anyone else who is interested, this is how I did it, not sure if it's the "correct" way:


/////////  IN MY REPORT ie report class ContractorMASSOrder.cs
// Report constructor
        public ContractorMASSOrder(int massOrderId)
        {
            // Just set variable, then setup at databinding.
            _massOrderId = massOrderId;
 
            InitializeComponent();
        }
 
    // Has to be done at runtime as Design time settings are different
        private void ContractorMASSOrder_ItemDataBinding(object sender, EventArgs e)
        {
 
            // Members to get data.
            oadsMassOrders.ObjectContextMember = "GetOrders"// gets a list of 1 massOrder.
            oadsMassOrders.Parameters.Add("massOrderId", typeof(int), _massOrderId);
 
            oadsMassOrderItems.ObjectContextMember = "GetOrderItems";
            oadsMassOrderItems.Parameters.Add("massOrderId", typeof(int), _massOrderId);
 
        }
 
 
/// extenstion of my entities model, ie ModelExtensions.cs
/// as per Telerik guidelines/doco.
namespace MassDataAccess
{
    public partial class MassModel
    {
        /// <summary>
        ///  Get 1 order only, used for report.
        /// </summary>
        /// <param name="massOrderId"></param>
        /// <returns></returns>
        public System.Linq.IQueryable<MassOrder> GetOrders(int massOrderId)
        {
            return this.MassOrders.Where(massOrder => massOrder.MassOrderId == massOrderId);       
        }
 
        /// <summary>
        ///  Get Order Items, used for reporting
        /// </summary>
        /// <param name="massOrderId"></param>
        /// <returns></returns>
        public System.Linq.IQueryable<MassOrderItem> GetOrderItems(int massOrderId)
        {
            return this.MassOrderItems.Where(massOrderItem => massOrderItem.MassOrderId == massOrderId);
        }
 
    }
}

Pat.
Tags
General Discussions
Asked by
Patrick Saunders
Top achievements
Rank 1
Answers by
Patrick Saunders
Top achievements
Rank 1
Share this question
or