Esempio n. 1
0
        List <T> IXapPoco.SelectList <T>(T obj)
        {
            try {
                List <T> lst = new List <T>();

                pocoMap = PocoMapService.Instance.GetPocoMap(obj);
                if (string.IsNullOrWhiteSpace(_dbConnectionContext.TSql))
                {
                    _dbConnectionContext.TSql = pocoMap.SelectListProcedure;
                }
                _dataProvider = DbFactory.Instance.Db(_dbConnectionContext);

                DoInsertUpdate(obj, PocoOperationType.SelectList);

                XapDataReader dr = _dataProvider.ExecuteReader();

                while (dr.Read())
                {
                    T newObj = Activator.CreateInstance <T>();

                    SetListPropertiesFromDataReader <T>(newObj, dr);

                    lst.Add(newObj);
                }
                return(lst);
            } catch (Exception ex) {
                throw new XapException($"Error performing select list for {typeof(T).FullName}", ex);
            } finally {
                _dataProvider.CloseConnection();
            }
        }
Esempio n. 2
0
        T IXapPoco.Select <T>(T obj)
        {
            try {
                pocoMap = PocoMapService.Instance.GetPocoMap(obj);

                if (string.IsNullOrWhiteSpace(_dbConnectionContext.TSql))
                {
                    _dbConnectionContext.TSql = pocoMap.SelectProcedure;
                }
                _dataProvider = DbFactory.Instance.Db(_dbConnectionContext);

                DoInsertUpdate(obj, PocoOperationType.Select);

                XapDataReader dr = _dataProvider.ExecuteReader();

                SetPropertiesFromDataReader <T>(obj, dr);

                return(obj);
            } catch (Exception ex) {
                throw new XapException($"Error performing select for {typeof(T).FullName}", ex);
            } finally {
                _dataProvider.CloseConnection();
            }
        }