// CONVIERTE ENTIDADES A OBJETOS DE WPF O SILVERLIGHT
        //<summary>
        // Convierte un DataModelEntity guardado en una base de datos a un objeto DataModel que se usa en proyectos wpf.
        // </summary>
        // <param name="dataModelEntity">objeto a nivel de capas inferiores</param>
        // <returns></returns>
        public static DataModel ConvertEntityToDataModel(DataModelEntity dataModelEntity)
        {
            DataModel dataModel = new DataModel();

            foreach (TableEntity tableEntity in dataModelEntity.Tables)
            {
                TableWpf table = ConvertEntityToTable(tableEntity);
                dataModel.AddTable(table);
            }
            foreach (RelationEntity relationEntity in dataModelEntity.Relations)
            {
                RelationWpf relation = GetRelationFromDataModelEntity(dataModel, relationEntity);
                dataModel.AddRelation(relation);
            }

            return(dataModel);
        }
        /// <summary>
        /// Busca una relacion en el modelo de datos y la retorna como un RelationWpf
        /// </summary>
        /// <param name="dataModel">modelo de datos</param>
        /// <param name="relationEntity">relacion</param>
        /// <returns>Un RelationWpf si existe la relacion en el modelo de datos, null si no existe.</returns>
        public static RelationWpf GetRelationFromDataModelEntity(DataModel dataModel, RelationEntity relationEntity)
        {
            TableWpf source = null;
            TableWpf target = null;

            foreach (TableWpf table in dataModel.Tables)
            {
                if (String.CompareOrdinal(relationEntity.Source.Name, table.Name) == 0)
                {
                    source = table;
                }
                if (String.CompareOrdinal(relationEntity.Target.Name, table.Name) == 0)
                {
                    target = table;
                }
            }
            if (source != null && target != null)
            {
                RelationWpf relation = new RelationWpf(source, target, (RelationType)relationEntity.RelationType);
                return(relation);
            }
            return(null);
        }