views:

50

answers:

2

I want to include a table (Events) from another database in my LINQ to SQL class.

How should I format the Data Source of that table?

I have tried with IP.dbo.Events, IP.DatabaseName.dbo.Events and so on, but can not get it to work.

The reason for all this is to select Events that a Client have attended.

I have also tried to have the table in another LINQ to SQL class, but then it complains on the Data Context.

public static IQueryable<Event> ByClientID(this IQueryable<Event> events, int clientID)
    {
        events = from e in events
                 from c in new MyDataContext().ClientCourses
                 where e.EventID == c.CourseID &&
                 c.ClientID == clientID
                 select e;

        return events;
    }
+1  A: 

You can only use tables that reside on the same physical SQL Server in two different instances. I did this once as someone had "cleverly" put an application's DB across two database instances.

There is a blog post on it here that may help.

RichardOD
A: 

Could you create a view that returns the data from the 2nd database and use this instead? (Not tried this so absolutely no idea if it'll work :)

Obviously this is no good if you need to be saving to the other database too..

Nick