I need to replace the characters ; and linebreak to the field p.notas. I tried this but it doesn’t replace the linebreaks.
var res = from p in miDataContext.clientes
orderby p.nombreCom
select
(p.nombreCom ?? "") + ";" +
(p.razon ?? "") + ";" +
(p.nif ?? "") + ";" +
((p.notas ?? "").Replace (";" ,"."))
.Replace(Environment.NewLine , ". ");
The problem with using
Environment.NewLinein yourReplace()call is that the newline character(s) in your environment my not necessarily match what is actually used in the string. Yours probably has\r\n(windows) but what is actually stored is just\n. That pattern is definitely not in the string in that case. You’ll have to check for all newline variants.Assuming this is all fine in LINQ to SQL, just add more replace calls for each of the newline types.