hasokeric
3/23/2015 - 6:51 PM

executeEpicorBAQ.cs

// Execute BAQ with parameter
using (var session = new Epicor.Mfg.Core.Session("user", "secret", "AppServerDC://server:port"))
{
    // DynamnicQuery for BAQ
    var dynamicQuery = new Epicor.Mfg.BO.DynamicQuery(session.ConnectionPool);

    // Build Parameters DS
    QueryExecutionDataSet executionDS = new QueryExecutionDataSet();

    // Actual parameter row
    var paramRow = executionDS.ExecutionParameter.NewRow();
    paramRow["ParameterName"] = "StartDate";
    paramRow["ParameterValue"] = "6/15/2011";
    paramRow["ValueType"] = "date";
    paramRow["IsEmpty"] = "False";
    paramRow["RowIdent"] = "";
    paramRow["RowMod"] = "";
    paramRow["DBRowIdent"] = new byte[0];
    executionDS.ExecutionParameter.Rows.Add(paramRow);

    // Out variable which indicates if more results are available (likely for use with topNRecords)
    bool hasMoreRecords;

    // Executed named BAQ with parameter
    var results = dynamicQuery.ExecuteByIDParametrized("01-NamedBAQ", executionDS, "", 0, out hasMoreRecords);

    // Store results
    results.WriteXml(@"c:\temp\BAQWithParamResults.xml");
}