Exemple #1
0
        private string MapCollection <T>(IEnumerable <T> collection, MapperBase mapper)
        {
            var builder = new StringBuilder();

            builder.Append(mapper.GetHeader());
            foreach (var item in collection)
            {
                builder.Append(mapper.MapObject(item));
            }
            return(builder.ToString());
        }
Exemple #2
0
 private void SetData(ref kurdev_portal_test entity, PortalTest portalTest)
 {
     Console.WriteLine(portalTest.UserId);
     MapperBase.GetMappers();
     entity = Mapper.Map <PortalTest, kurdev_portal_test>(portalTest);
     //entity = d;
     //entity.kurdev_Login = portalTest.Login;
     //entity.kurdev_Role = new OptionSetValue((int)portalTest.Role);
     //entity.kurdev_name = portalTest.Name;
     //entity.kurdev_PassWord = portalTest.Password;
 }
Exemple #3
0
        private void SetDataForUpdate(ref kurdev_portal_test crmEntity, PortalTest importEntity, Guid id)
        {
            var tmp = importEntity;

            if (importEntity.UserId == Guid.Empty)
            {
                tmp.UserId = crmEntity.Id;
            }
            Console.WriteLine(tmp.UserId);
            Console.WriteLine(tmp.Login);
            MapperBase.GetMappers();
            crmEntity = Mapper.Map <PortalTest, kurdev_portal_test>(tmp);
        }
        public void Test()
        {
            User user = new User
            {
                UserName     = "******",
                Id           = 1,
                UserPassword = "******",
                CreateDate   = DateTime.Parse("2015-02-11 09:35:19")
            };

            //MapperBase<UserModel, User> mapper = new MapperBase<UserModel, User>();
            //UserModel userModel = mapper.GetModel(user);


            MapperBase <User, UserModel> mapper2 = new MapperBase <User, UserModel>();
            UserModel userModel2 = mapper2.GetEntity(user);
        }
Exemple #5
0
        public List <PlaceName> FindPlaceNames(string find, int maxrows = 1000)
        {
            List <PlaceName> list = new List <PlaceName>();

            try {
                string sql = "SELECT tPlace as Name, tType as PlaceType, tDivision as Division, tLatitude as LatitudeString, tLongitude as LongitudeString, dblLatitude as Latitude, dblLongitude as Longitude FROM tblGaz WHERE tPlace like @find ORDER BY tDivision, tPlace, tType LIMIT @limit";
                SelectReader(sql, (reader) => {
                    PlaceName place = new PlaceName();
                    MapperBase.ReflectMap(place, reader, null, null);
                    list.Add(place);
                }, new SQLiteParameter("@find", find + "%"), new SQLiteParameter("@limit", maxrows));
            } catch (Exception ex) {
                GlobalExceptionHandler.Handle(ex);
            }

            return(list);
        }
Exemple #6
0
        public Collection <T> Execute()
        {
            Collection <T> coleccion = new Collection <T>();

            using (IDbConnection connection = GetConnection())
            {
                IDbCommand command = connection.CreateCommand();
                command.Connection  = connection;
                command.CommandText = this.CommandText;
                command.CommandType = this.CommandType;
                //Agregando parametros al comando
                foreach (IDbDataParameter parametro in this.GetParameters(command))
                {
                    command.Parameters.Add(parametro);
                }
                try
                {
                    connection.Open();
                    //Leyendo la informacion
                    using (IDataReader lector = command.ExecuteReader())
                    {
                        try
                        {
                            MapperBase <T> mapper = GetMapper();
                            coleccion = mapper.MapAll(lector);
                            return(coleccion);
                        }
                        catch (Exception)
                        {
                            //cerramos la conexion
                            connection.Close();
                            //cerramos el lector
                            lector.Close();
                            throw;
                        }
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Exemple #7
0
        public Collection <T> Execute()
        {
            Collection <T> collection = new Collection <T>();

            using (IDbConnection connection = GetConecction())
            {
                IDbCommand command = connection.CreateCommand();
                command.Connection  = connection;
                command.CommandText = this.CommandText;
                command.CommandType = this.CommandType;

                foreach (IDbDataParameter parametro in this.GetParameters(command))
                {
                    command.Parameters.Add(parametro);
                }
                try
                {
                    connection.Open();
                    using (IDataReader lector = command.ExecuteReader())
                    {
                        try
                        {
                            MapperBase <T> mapper = GetMapper();
                            collection = mapper.MapAll(lector);
                            return(collection);
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                        finally
                        {
                            lector.Close();
                        }
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Exemple #8
0
        public List <PlaceName> GetPlacesInBoundedBox(double x1, double y1, double x2, double y2, string placeType)
        {
            var list = new List <PlaceName>();

            try {
                string sql = "SELECT tPlace as Name, tType as PlaceType, tDivision as Division, tLatitude as LatitudeString, tLongitude as LongitudeString, dblLatitude as Latitude, dblLongitude as Longitude FROM tblGaz WHERE (dblLatitude BETWEEN @y1 AND @y2) AND (dblLongitude BETWEEN @x1 AND @x2)";
                if (!string.IsNullOrEmpty(placeType))
                {
                    sql += " and tType = @div";
                }
                SelectReader(sql, (reader) => {
                    PlaceName place = new PlaceName();
                    MapperBase.ReflectMap(place, reader, null, null);
                    list.Add(place);
                }, new SQLiteParameter("@y1", y1), new SQLiteParameter("@y2", y2), new SQLiteParameter("@x1", x1), new SQLiteParameter("@x2", x2), new SQLiteParameter("@div", placeType));
            } catch (Exception ex) {
                GlobalExceptionHandler.Handle(ex);
            }

            return(list);
        }
Exemple #9
0
 private static T Convert <T>(string value)
 {
     return((T)MapperBase.ConvertValue(typeof(T), value, (t, v) => v));
 }
 /// <summary>
 ///   Initializes a new instance of the <see cref="Mapper" /> class.
 /// </summary>
 /// <param name="mapperImpl">The mapper impl.</param>
 public Mapper(MapperBase mapperImpl)
 {
     _mapperImpl = mapperImpl;
 }
 public MappingTest(MapperBase mapper)
 {
     Mapper = mapper;
 }
Exemple #12
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="MapperDescription" /> class.
 /// </summary>
 /// <param name="mapper">The mapper.</param>
 /// <param name="key">The key.</param>
 /// <param name="id">The id.</param>
 public MapperDescription(MapperBase mapper, MapperKey key, int id)
 {
     Mapper = mapper;
     Key    = key;
     Id     = id;
 }
Exemple #13
0
 public RepositoryBase(FlightDbContext dbContext, MapperBase <TEntity, TDto> mapper)
 {
     this.Mapper    = mapper;
     this.DbContext = dbContext;
 }