The main problem is that I recieve the following message:

"base {System.SystemException} = {"Unable to create a constant value of type 'BokButik1.Models.Book-Author'. Only primitive types ('such as Int32, String, and Guid') are supported in this context."}"

based on this LinQ code:

IBookRepository myIBookRepository = new BookRepository();
    var allBooks = myIBookRepository.HamtaAllaBocker();

    IBok_ForfattareRepository myIBok_ForfattareRepository = new Bok_ForfattareRepository();
    var Book-Authors = myIBok_ForfattareRepository.HamtaAllaBok_ForfattareNummer();

    var q = from booknn in allBooks
            join Book-Authornn in Book-Authors on booknn.BookID equals Book-Authornn.BookID
            select new { booknn.title, Book-AuthorID };

How shall I solve this problem to get a class instance that contain with property title and Book-AuthorID?

// Fullmetalboy

I also have tried making some dummy by using "allbooks" relation with Code Samples from the address http://www.hookedonlinq.com/JoinOperator.ashx. Unfortunately, still same problem.

I also have taken account to Int32 due to entity framework http://msdn.microsoft.com/en-us/library/bb896317.aspx. Unfortunatley, still same problem.

Using database with 3 tables and one of them is a many to many relationship. This database is used in relation with entity framework

Book-Author
Book-Author (int)
BookID (int)
Forfattare (int)

Book
BookID (int)
title (string)
etc etc etc

Take a look at:

var result = from book in allbooks
                     join author in bookauthors on book.BookID equals author.BookId
                     select new { BookID = book.BookID, Title = book.Title, AuthorBookID = author.Book_Author, Forfattare = author.Forfattare};

Take a look at:

var result = from book in allbooks
                     join author in bookauthors on book.BookID equals author.BookId
                     select new { BookID = book.BookID, Title = book.Title, AuthorBookID = author.Book_Author, Forfattare = author.Forfattare};

I still recieve the same problem when I tried your proposal.

You can attach your project here (include database ) if possible.

You can attach your project here (include database ) if possible.

It can be very difficult to apply the source code in the textbox because I doing a webbshop created in ASP.net MVC 2.

The database is created in SQL express with drop and click ability.

If you are still interrested, I can send the whole work via email or another way. Maybe you have a better solution?

>I can send the whole work via email or another way. Maybe you have a better solution?

It is against forum rules.

You need to create a "sample" (new project) application, add those tables and programs needed to sort out your problem and we can discuss that issue on board.

>I can send the whole work via email or another way. Maybe you have a better solution?

It is against forum rules.

You need to create a "sample" (new project) application, add those tables and programs needed to sort out your problem and we can discuss that issue on board.

I found the main problem. I shouldn't combine generic List with LinQ IQuery together with Join.

Thanks for your help!

You are welcome! No problem, glad I could help. Please mark this thread as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.