Beispiel #1
0
        /// <summary>
        /// Loads the one.
        /// </summary>
        /// <param name="commandText">The command text.</param>
        /// <param name="commandBehavior">The command behavior.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns></returns>
        public T LoadOne(String commandText, System.Data.CommandBehavior commandBehavior, params SqlCeParameter[] parameters)
        {
            _affectedRows = 0;
            using (SqlCeDataReader reader = _dataAccess.GetDataReader(commandText, commandBehavior, parameters)) {
                var builder = new ReflectionBuilder <T>();

                while (reader.Read())
                {
                    _affectedRows += 1;
                    return(builder.Build(reader));
                }
            }
            return(default(T));
        }
Beispiel #2
0
        /// <summary>
        /// Loads the observable collection.
        /// </summary>
        /// <param name="commandText">The command text.</param>
        /// <param name="commandBehavior">The command behavior.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns></returns>
        public ObservableCollection <T> LoadObservableCollection(String commandText, System.Data.CommandBehavior commandBehavior, params SqlCeParameter[] parameters)
        {
            var objResult = new ObservableCollection <T>();

            using (SqlCeDataReader reader = _dataAccess.GetDataReader(commandText, commandBehavior, parameters)) {
                var builder = new ReflectionBuilder <T>();

                while (reader.Read())
                {
                    objResult.Add(builder.Build(reader));
                }
            }
            _affectedRows = objResult.Count;
            return(objResult);
        }
Beispiel #3
0
        /// <summary>
        /// Loads the list.
        /// </summary>
        /// <param name="commandText">The command text.</param>
        /// <param name="commandBehavior">The command behavior.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns></returns>
        public List <T> LoadList(String commandText, System.Data.CommandBehavior commandBehavior, params SqlCeParameter[] parameters)
        {
            var result = new List <T>();

            using (SqlCeDataReader reader = _dataAccess.GetDataReader(commandText, commandBehavior, parameters)) {
                var objBuilder = new ReflectionBuilder <T>();

                while (reader.Read())
                {
                    result.Add(objBuilder.Build(reader));
                }
            }
            _affectedRows = result.Count;
            return(result);
        }