Solved

Problem with LINQ to entities on a XML field in database

Posted on 2009-05-07
1
557 Views
Last Modified: 2013-11-11
I've a problem:

I try to access to a database with the code below, but I've an error:

System.Data.EntityCommandExecutionException: Une erreur s'est produite lors de l'exécution de la définition de la commande. Pour plus de détails, consultez l'exception interne. ---> System.Data.SqlClient.SqlException: Disallowed implicit conversion from data type xml to data type nvarchar, table 'dbo.Fournisseurs', column 'Informations'. Use the CONVERT function to run this query.

I think it's the database that say this error, but what can I do? Because I'm using Linq to Entity, It's not me who write this query.
using (geststockEntities gse = new geststockEntities("name=geststockEntitiesTechnicien"))

            {

                IQueryable<Fournisseurs> fourns = gse.Fournisseurs.Where(f => f.Informations.Contains(prefixText));

                res = new String[fourns.Count()];
 

                int i = 0;

                foreach (Fournisseurs f in fourns)

                {

                    XElement fournisseur = XElement.Parse(f.Informations.ToString());

                    res[i++] = fournisseur.Element("nom") + " (ID #" + f.ID_fournisseur + ")";

                }

            }

Open in new window

0
Comment
Question by:Nargzul
1 Comment
 
LVL 11

Accepted Solution

by:
Salim Fayad earned 500 total points
ID: 24339725
try to replace line 2 by the following:

IQueryable<Fournisseurs> fourns = gse.Fournisseurs.Where(f => f.Informations.ToString().Contains(prefixText));

Open in new window

0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now