lets say I have a SP in SQL :
CREATE PROCEDURE mySP
@LastName nvarchar(10),
@FirstName nvarchar(20)
AS
...
GO
In c# there isn’t string type with specified length. its max length is 2^32-1 ( IMHO)
So , What kind of protection does the C# developer has for : not to send string with exceeding length ?
( I don’t think any ORM also has this restriction – maybe i’m wrong).
The only way (I see ) is to read the Sp params before(!) and keep in cache , and then to build some kind of proxy which will be responsible for this.
But still – i’m afraid it would only fail at runtime.
Am i right ?
What are the solutions for this ?
C# doesn’t have limited-length strings, the checks will have to be done at run-time. It depends on the ORM you use, though. EntityFramework has a
MaxLengthattribute you can use to decorate strings.