Category Archives: Entity Framework 4.0

.NET Entity Layer The member with identity ‘Result’ does not exist in the metadata collection

“The member with identity ‘Result’ does not exist in the metadata collection.
Parameter name: identity”

If you have stumbled across this error when trying to perform a transaction against your DB or any other action via your entity layer. If it is indeed a Microsoft SQL Database or any other database I would highly recommend you disable triggers on the affected tables and re run your test.

This error is the entity layer running home to its default error when either the error cannot be translated or the what ever is being returned from the transaction cannot be understood.

So if you stumble across this error, its because the entity layer is performing an operation that is causing a secondary separate operation which is where the underlying error is kicking back from, either because an error was raised or because the return is in an unexpected format.

VAT Information Exchange System (VIES)

What is the VIES ?
It is an electronic means of transmitting information relating to VAT-registration (= validity of VAT-numbers) of companies registered in EU. Furthermore, information relating to (tax exempt) intra-Community supplies between Member States’ administrations is also transmitted via VIES

The Taxation and Custom Union has provided us developers a nice little webservice to use for validating VAT numbers realtime.

This is their public facing page for one off manual validation
The service to be used by your application can be found here

The FAQ is here

Ok so now i will demonstrate how to use this in your Visual Studio based application

If you have Visual Studio 2010, and your building a web app, in solution explorer right click the web app root node and you should see “Add Web Reference”, this will present you with the “Add Web Reference” dialog box
Paste the above web reference link into the “URL” and hit the “GO” green arrow

VIES Visual Studio Web Reference

Now Hit “Add Reference” and Visual Studio creates the Web Server Proxy and Wrapper Class.
Ok so now your project has the reference lets see how to use it

On your page that you wish to validate a vat number you should do the following
1. Collect a valid 2 character country code from the User
2. Collect a valid vat number from the User
3. Perform the needed filter on both of these values prior to envoking the webservice
4. Verify the return from the service and take action

First off you will need to import the reference into your page. For ease I use vb, C# will be similar and there are plenty of converters out there to see the code in c#

now your ready to use the reference
For this example we will be supplying country code and VAT number only. There are various other methods available but this suited me so its the only demo you will be getting.
The rules
1.The country code must be valid
2. The VAT number must contain no spaces and only be numerical numbers
3. We pass the validation boolean as a byref, if you also wanted to see what the company name and address the EU have on file for the company the webservice verified, you can pass two strings “Name” and “address” byref and view the content upon return.

This is how i do it

Most of the above code is preparation, there are very few ines tha perform the webservice method.
The actual call is made in the try catch

My particular app verifies the value of IsValid in the calling function, how you validate the values is up to you, on asuccessful return the value will be true and the byref Name and Add will contain the registered company name and address.

For your reference there is also another way to reference the web service described here

LINQ to Entities does not recognize the method ‘System.String ToString()’ method

If you use the entity framework from microsoft, latest version at the date of this post is framework 4.0
You might run into this little angel when you try to envoke the string value of an object

LINQ to Entities does not recognize the method ‘System.String ToString()’ method

This happens when applying a filter to an integer field and you want to use the

method of a string. So my code looked ike this

From the master query


The only way i Could get round this was to onvert the UID field into a string in the master select query like so

notice the cure was to force linq to convert the resulting field into a string, allowing the filter to look like this

Microsoft have a list os supported methods here