views:

444

answers:

2

Hello

I just switched from Linq to entities framework, and I'm having problems with methods that returns "all rows". I get: "The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not referenced" error in my "service layer" that calls the data-layer.

I get an error on:

BookingObjectRepository _repository = new BookingObjectRepository();

public IQueryable GetBookingObjects() { return _repository.GetBookingObjects(); }

and in the "data-layer" I have:

BookingsystemEntities _entities = new BookingsystemEntities();

public IQueryable<BookingObject> GetBookingObjects()
    {
        return from bo in _entities.BookingObjectSet
               select bo;
    }

UPDATE: Filter items, they are "physically" in Filters-folder but namespace is same as the emdx file uses.

using System; using System.Collections.Generic; using System.Linq; using System.Text;

namespace BookingSystem.Data.Models {

public static class BookingObjectFilters
{public static IQueryable<BookingObject> ByBookingObjectID(this IQueryable<BookingObject> qry, int bookingobjectID)
{
return from bo in qry
               where bo.BookingObjectID == bookingobjectID
               select bo;
}
+1  A: 

Do you have

using System.Data;
using System.Data.Objects.DataClasses;

in your usings?

and

public IQueryable GetBookingObjects() { return _repository.GetBookingObjects(); }

should probably be

public IQueryable<BookingObject> GetBookingObjects() { return _repository.GetBookingObjects(); }

Hope that helps,

Dan

Daniel Elliott
where shall I add that? in my repository in data layer?
molgan
aye, in repository in DAL
Daniel Elliott
Still same error :(
molgan
Check the edit sir, noticed a problem with signature of method
Daniel Elliott
its like that, the code-edit here hide it
molgan
http://svevarn.com/BookingObjectsService.txthttp://svevarn.com/BookingObjectRepository.txt
molgan
What namespace is BookingObject in please?
Daniel Elliott
Haven't defined any except in the designer-file in the edmx file
molgan
Check namespace on the designer file in EDMX and add to the srvice layer usings.Kindness, Dan
Daniel Elliott
Now that works, but for some reason it complains about the: public IQueryable<BookingObject> GetBookingObjects(int bookingobjectID) { return _repository.GetBookingObjects().ByBookingObjectID(bookingobjectID); }eventhough my "ByBookingObjectID-filter" is in same namespace
molgan
Post the code to the filter and let's have a look!! :)
Daniel Elliott
ah, you will need a reference to the EDMX namespace in the filter too!
Daniel Elliott
posted update, messed up on the code-format though
molgan
hmm, seems like the first problem still is there :S
molgan
added a reference to service-layer and error disapeared... hope it wont cause problems later
molgan
+1  A: 

Your system must have .NET 3.5 SP 1 or better installed, and your project must reference the System.Data.Entity assembly (look at the references node in Solution Explorer).

Craig Stuntz