0

I'm in the process of building a WCF Service Application which connects to an SQL Database using Entity SQL (Entity Framework). At the moment I keep getting this error with several methods:

The data reader has more than one field. Multiple fields are not valid for EDM primitive or enumeration types.

This is an example of one of the methods and would appreciate some advice on how to approach this:

public string[] Tables()
    {
        string Sql = @"SELECT * FROM information_schema.tables";

        using (var Context = new XEntities())
        {
            Context.Database.Connection.Open();

            IEnumerable<string> Query = Context.Database.SqlQuery<string>(Sql);              
            string[] results = Query.ToArray();

            Context.Database.Connection.Close();

            return results;

        }

The method is supposed to query the database for a list of tables and send them back in an array. This will then be inputted into a ListBox by the Windows Phone App.

Thank You for your time.

1 Answer 1

1

Modify your query to select the column you want to populate Query with:

string Sql = @"SELECT TABLE_NAME FROM information_schema.tables";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.