Crear clase C# desde tabla SQL

Usar lo siguiente

declare @TableName sysname = 'TableName'
declare @Result varchar(max) = 'public class ' + @TableName + '
{'

select @Result = @Result + '
public ' + ColumnType + NullableSign + ' ' + ColumnName + ' { get; set; }
'
from
(
select
replace(col.name, ' ', '_') ColumnName,
column_id ColumnId,
case typ.name
when 'bigint' then 'long'
when 'binary' then 'byte[]'
when 'bit' then 'bool'
when 'char' then 'string'
when 'date' then 'DateTime'
when 'datetime' then 'DateTime'
when 'datetime2' then 'DateTime'
when 'datetimeoffset' then 'DateTimeOffset'
when 'decimal' then 'decimal'
when 'float' then 'float'
when 'image' then 'byte[]'
when 'int' then 'int'
when 'money' then 'decimal'
when 'nchar' then 'char'
when 'ntext' then 'string'
when 'numeric' then 'decimal'
when 'nvarchar' then 'string'
when 'real' then 'double'
when 'smalldatetime' then 'DateTime'
when 'smallint' then 'short'
when 'smallmoney' then 'decimal'
when 'text' then 'string'
when 'time' then 'TimeSpan'
when 'timestamp' then 'DateTime'
when 'tinyint' then 'byte'
when 'uniqueidentifier' then 'Guid'
when 'varbinary' then 'byte[]'
when 'varchar' then 'string'
else 'UNKNOWN_' + typ.name
end ColumnType,
case
when col.is_nullable = 1 and typ.name in ('bigint', 'bit', 'date', 'datetime', 'datetime2', 'datetimeoffset', 'decimal', 'float', 'int', 'money', 'numeric', 'real', 'smalldatetime', 'smallint', 'smallmoney', 'time', 'tinyint', 'uniqueidentifier')
then '?'
else ''
end NullableSign
from sys.columns col
join sys.types typ on
col.system_type_id = typ.system_type_id AND col.user_type_id = typ.user_type_id
where object_id = object_id(@TableName)
) t
order by ColumnId

set @Result = @Result + '
}'

print @Result

Error Reporting en aplicacion web MVC .NET

El error era:

Could not load file or assembly ‘Microsoft.ReportViewer.Common, Version=xx.0.0.0, Culture=neutral, PublicKeyToken=’xxx’ or one of its dependencies.

 

Url con la solucion:

http://msm2020-sc.blogspot.pe/2013/05/could-not-load-file-or-assembly.html

Archivos necesarios al desplegar:

https://my.pcloud.com/publink/show?code=kZhRXxZtfwOD3113yF2oXGUmP0b3Vjl7Pok

Error con JavaScriptSerializer de JSON. La longitud de la cadena supera el valor establecido en la propiedad maxJsonLength

Error generado por .NET

Error durante la serialización o deserialización mediante JavaScriptSerializer de JSON. La longitud de la cadena supera el valor establecido en la propiedad maxJsonLength.

Se intento con (-no funcionó)

<system.web.extensions>
   <scripting>
      <webServices>
          <jsonSerialization maxJsonLength="50000000"/>
      </webServices>
   </scripting>
</system.web.extensions>

Funcionó, asignado el valor en tiempo de ejecución, no se usó lo anterior:

List<Colaborador_BE> listaColaborador=oColaborador_SD.Listar(pColaborador_BE);
 var serializer=new System.Web.Script.Serialization.JavaScriptSerializer();
 serializer.MaxJsonLength=500000000;

var json = Json(listaColaborador, JsonRequestBehavior.AllowGet);
 json.MaxJsonLength = 500000000;
 return json;