varchar(最大) + LINQ 到 SQL
我有一个 varchar(max) 列,我正在尝试读取该列,但该字段被截断为 4,000 个字符。我见过类似的问题,但是他们在sql这边。
我需要做什么才能获得整个字段?
例如:
using (DataContext dc = new DataContext())
{
var foo = dc.foos.First();
if (foo.Formula2.Length > 4000)
{
Console.WriteLine("success!");
}
}
我尝试过 设置 TextSize 之类的东西,但它没有'没有区别。:
dc.ExecuteCommand("SET TEXTSIZE 100000;");
var foo = dc.foos.First();
更新:
服务器数据类型是 varchar(max)。有问题的字段是公式2:
如果我尝试将类型更改为不同的类型,例如对象,我会收到消息“DbType 之间的映射”不支持“t_PriceFormula”类型的“Formula2”列中的“VarChar(MAX)”和类型“System.Object”。'
有什么建议吗?
I've got a varchar(max) column I'm trying to read but the field is being truncated at 4,000 characters. I've seen similar questions, but they are on the sql side.
What do I need to do to get the entire field?
Eg:
using (DataContext dc = new DataContext())
{
var foo = dc.foos.First();
if (foo.Formula2.Length > 4000)
{
Console.WriteLine("success!");
}
}
I've tried things like setting TextSize but it didn't make a difference.:
dc.ExecuteCommand("SET TEXTSIZE 100000;");
var foo = dc.foos.First();
UPDATE:
The server data type is varchar(max). The field in question is formula2:
If I try and change the type to something different like Object, I get message 'Mapping between DbType 'VarChar(MAX)' and Type 'System.Object' in Column 'Formula2' of Type 't_PriceFormula' is not supported.'
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
感谢888。
这看起来有点复杂,但它确实有效。
将字段转换为数组,然后再转换回字符串。
With thanks to 888.
This seems a little convoluted but it worked.
Convert the field to an array, then back to a string.
听起来像 .net 将 varchar 转换为 nvarchar
我不知道如何直接解决它。但 System.Text.Encoding 可能有帮助
试试这个
sounds like .net convert varchar to nvarchar
i dont know how to directly solve it. but System.Text.Encoding might help
try this