How to use SUM in a string field, converting the value to int?

1

I have a table that has a PA field that is string , it stores a 10-digit number and I can not change the type of it because it references another table.

I'm trying to add this field like this:

Int32 somaBpaC = modelOff.bpacs.Sum(p => p.pa);

I get an error already expected that can not add the field pa which is string .

Is there any way to convert the field to int at the time of the sum?

    
asked by anonymous 25.08.2017 / 21:10

1 answer

2

tried to parse the value:

Int32 somaBpaC = modelOff.bpacs.Sum(p => int.Parse(p.pa));
    
25.08.2017 / 21:19