I am using WCF Data Services (OData) to expose some data that is a varchar(10) in my SQL Server Database. (I am using entity framework to expose it.)
Is there a way to ask the OData endpoint how long a string can be (ie get the 10 from varchar(10))?
If the service is an EF based service, and your CSDL for the EF model contains the max string length attribute on the property, then the $metadata of the service will contain that attribute as well. The client can then parse the $metadata and ask for this.
Note that the WCF DS Client library doesn’t have an API to do this though. You could use ODataLib and EdmLib to read the $metadata (or just plain XML). They are in Microsoft.Data.OData.dll and Microsoft.Data.Edm.dll in the latest CTP (http://blogs.msdn.com/b/astoriateam/archive/2011/10/13/announcing-wcf-data-services-oct-2011-ctp-for-net-4-and-silverlight-4.aspx).
Note though, that if the service is based on something else than EF, then it’s currently not possible to customize the $metadata endpoint in WCF DS itself this way. You would have to expose the $metadata yourself in some other way.