It would be nice to do this, but there isn't a translation for Convert functions to (generic) SQL:
var result = dbContext.Users.Sum(s => Convert.ToInt32(s.Age));
This should work instead:
var result = dbContext.Users
.Select(x => x.Age) // We only need one field, not the whole user object.
.ToArray() // Run the SQL and bring over the array of short/byte
.Sum(); // Client-side Sum method accepts byte or short.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…