igor-tkachev / bltoolkit

Business Logic Toolkit for .NET
MIT License
297 stars 112 forks source link

MaxLengthAttribute Int Size is too small #379

Closed psliurt closed 8 years ago

psliurt commented 8 years ago

We have a MySql database, there is a column which is set datatype to [ longtext ] with size "4294967295" .

After I used the .tt file to generate my data model. It raises an error about MaxLengthAttribute. The MaxLengthAttribute using int as parameter, but the database columns is [ longtext ]. [ longtext ] convert to C# datatype should be " uint ". So, an error comes.

Following is my .tt file.

`<#@ template language="C#" debug="True" hostspecific="True" #> <#@ output extension=".cs" #> <#@ assembly name="$(SolutionDir)\packages\MySql.Data.6.9.8\lib\Net40\MySql.Data.dll" #> <#@ include file=".\BLToolkit.ttinclude" #> <#@ include file=".\MySql.ttinclude" #> <#@ include file=".\ValidationAttributes.ttinclude" #> <# GetConnectionObject = () => new MySql.Data.MySqlClient.MySqlConnection(); ConnectionString = "Server=localhost;Port=3306;Database=mydatabase;Uid=test;Pwd=test;charset=utf8;";

DataContextName     = "MyModel";
Namespace           = "MyModel.Test";

GenerateModel();

>`

the property of the column the .tt file generates like following

[Nullable, MaxLength(4294967295), Required] public string payload { get; set; } // longtext(4294967295)

Is there any solution can solve this problem?

ili commented 8 years ago

may be we can change it and use uint for. ex...

ili commented 8 years ago

please, check and close issue if fixed

psliurt commented 8 years ago

I have downloaded the branch- dev , and compiled.(I found that I have to ensure the Sliverlight sdk is installed on my machine)

Now , It works for my case, thanks for your contribute.