1

In T-SQL, I can write:

select datalength(somecolumn_that_is_defined_as_text) from somedatabase

and it returns the length, in bytes, of that column.

Can this be done in using a Lambda expression?

Bridge
  • 29,818
  • 9
  • 60
  • 82
Erik Lane
  • 11
  • 1

2 Answers2

1

It looks like they added it in .Net 4.0

You should be able to add it to 3.5 at least by using EdmFunctionAttribute on your own function call (I'm not finding a good example of this right now)

EdmFunctionAttribute is .Net 4.0 too. So I can't find any way to achieve this in .Net 3.5 Lambda statements.

Thymine
  • 8,775
  • 2
  • 35
  • 47
0

Maybe use Encoding.GetBytes(MyColumnValue).Length on the values?

Mike Cheel
  • 12,626
  • 10
  • 72
  • 101
  • This is not valid because that would give the bytes in CLR after its been converted from the SQL datatype (So it would give the string's bytes not the nvarchar's bytes) and would only work on strings – Thymine Feb 08 '12 at 21:34