Example #1
0
        public T GetTableObject <T>(string pStrWhereFieldName, string pStrWhereFieldValue, string pStrTableName) where T : Table
        {
            SAPbobsCOM.Recordset        lObjRecordSet     = null;
            Dictionary <string, string> lLstStrParameters = null;
            string lStrQuery = "";

            try
            {
                lObjRecordSet = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(BoObjectTypes.BoRecordset);

                lLstStrParameters = new Dictionary <string, string>();
                lLstStrParameters.Add("WhereFieldName", pStrWhereFieldName);
                lLstStrParameters.Add("WhereFieldValue", pStrWhereFieldValue);
                lLstStrParameters.Add("TableName", pStrTableName);

                lStrQuery = this.GetSQL("GetObjectTemplate").Inject(lLstStrParameters);
                lObjRecordSet.DoQuery(lStrQuery);

                if (lObjRecordSet.RecordCount > 0)
                {
                    return(lObjRecordSet.GetTableObject <T>());
                }
                return(null);
            }
            catch (Exception lObjException)
            {
                throw new QueryException(lObjException.Message, lObjException);
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjRecordSet);
            }
        }