954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

LINQ in C# doesnt work, why? v2

private void displayWith1Criteria(string column, string value)
        {
            Console.WriteLine("entering _1_ display method");
            dbcontent = new DBtestEntities();
            var studienummerQuery = from members in dbcontent.Medlemmer.Include("Retninger")
                                    where column == value
                                    orderby members.Fornavn
                                    select new { Studienr = members.Studienummer, Fornavn = members.Fornavn, Efternavn = members.Efternavn, Email = members.Email, Studiested = members.Studiested, Betaling = members.BetalingsType, Uddannelses_Retning = members.Retninger.retningNavn };

            dataGridView1.DataSource = studienummerQuery;
        }


Doesnt return any data at all...

column is being called with members.Fornavn (Fornavn = a column name)
value = Anders (one of the data's in Fornavn column)

AMetnik
Newbie Poster
20 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

Without knowing what column, value and dbcontent contains there is no way to answer your question. Also, what's the point of passing in two parameters that you only use to compare to each other (line 6)?

Momerath
Nearly a Senior Poster
3,386 posts since Aug 2010
Reputation Points: 1,232
Solved Threads: 558
 

Well coloumn and value i have given examples off.
And dbcontent is an entity "class".. of a database i have made.

AMetnik
Newbie Poster
20 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

What content is in the variables? Did you pass the same string for column and value? Is there anything loaded into dbcontent, and if so, what?

Momerath
Nearly a Senior Poster
3,386 posts since Aug 2010
Reputation Points: 1,232
Solved Threads: 558
 

My database is loaded into dbcontent using a .edmx file from ABO entity class.
My database consist of 2 tables, "Retninger" and "Medlemmer".
Medlemmer contains columns things like Fornavn(in english, Firstname), Efternavn(Lastname), Studienummer(study no.)
What i would like is a "dynamic" method that can set both which column to be searched in and the value that needs to be searched for in the set column.

AMetnik
Newbie Poster
20 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: