Noticias de hoy viernes, 22 de noviembre de 2019, Critza - Portada

  • Armando4113@critza.com
    Script para obtener la definición de una tabla en Sql Server.

    SELECT
    	OBJECT_NAME(C.OBJECT_ID) AS 'Tabla'
    	,C.name AS 'Columna'
    	,SCHEMA_NAME(T.schema_id) AS 'Esquema'
    	,T.name AS 'Tipo'	
    	,C.max_length AS 'Tamaño Maximo en Bytes'
    	,C.precision AS 'Precisión'
    	,C.scale AS 'Escala'
    FROM 
    	sys.columns AS C
    JOIN 
    	sys.types AS T 
    ON 
    	C.user_type_id = T.user_type_id
    WHERE 
    	OBJECT_NAME(C.OBJECT_ID)='Card' 
    ORDER BY 
    	C.OBJECT_ID;




    Autor/Fuente: [email protected]
  • Armando4113@critza.com
    Validar correo electrónico en C#

            /// <summary>
            /// Método para validar si una cadena cumple con la condición de ser correo electrónico.
            /// </summary>
            /// <param name="value">Valor a validar.</param>
            /// <returns>Resultado de la validación.</returns>
            public bool ValidateEmail(string value)
            {
                bool result = false;
    
                try
                {
                    MailAddress mailAddress = new MailAddress(value);
                    result = mailAddress.Address.Equals(value, StringComparison.OrdinalIgnoreCase);
                }
                catch (Exception)
                {
                    result = false;
                }
    
                return result;
            }

     




    Autor/Fuente: [email protected]
  • Armando4113@critza.com
    Switch(Type) en C#

           private bool SwitchWithDataType(Type dataType, object value)
            {
                bool result = false;
    
                Dictionary<Type, Action> @switch = new Dictionary<Type, Action>
                {
                    {
                        typeof(short), () => { result = TryParseToShort(value); }
                    },
                    {
                        typeof(int), () =>{ result= TryParseToInt(value); }
                    },
                    {
                        typeof(long), () =>{ result= TryParseToLong(value); }
                    },
                    {
                        typeof(string), ()=>{ result=  TryParseToString(value); }
                    }
                };
    
                @switch[dataType]();
    
                return result;
            }

     




    Autor/Fuente: [email protected]