Using LINQ to SQL with multiple databases

I am working on a new project and hoping to use LINQ to SQL for the data
access but have come across the following issue.

I need to have my application access 3 databases with similar but not
the same table structure, for example

Database1 and Database 2 has a table called tblCustomer with 2 columns
CustomerKey and CustomerName

Database2 has a table called tblCustomer with 3 columns CustomerKey,
CustomerName and CustomerPostCode

I am looking for a solution that will allow me a query all three
databases without the need for 3 GetCustomerList functions as Database1
and Database2 could use the same function as are the same structure,
with an override function for database 3 to bring back the additional
field.

Is there a way i can declare a base datacontext class to handle Database
1 and 2 with an inherited version for Database 3.

Thanks In Advance

Stuart Ferguson





*** Sent via Developersdex http://www.developersdex.com ***
0
Stuart
5/6/2010 10:17:16 PM
dotnet.languages.csharp 1931 articles. 0 followers. Follow

1 Replies
1126 Views

Similar Articles

[PageSpeed] 2

Stuart Ferguson wrote:
> I am working on a new project and hoping to use LINQ to SQL for the data
> access but have come across the following issue.
> 
> I need to have my application access 3 databases with similar but not
> the same table structure, for example
> 
> Database1 and Database 2 has a table called tblCustomer with 2 columns
> CustomerKey and CustomerName
> 
> Database2 has a table called tblCustomer with 3 columns CustomerKey,
> CustomerName and CustomerPostCode
> 
> I am looking for a solution that will allow me a query all three
> databases without the need for 3 GetCustomerList functions as Database1
> and Database2 could use the same function as are the same structure,
> with an override function for database 3 to bring back the additional
> field.
> 
> Is there a way i can declare a base datacontext class to handle Database
> 1 and 2 with an inherited version for Database 3.
> 
> Thanks In Advance
> 

If you're talking about going to the designer and start changing code, I 
wouldn't advise it.

You should just add the 3 databases with the tables needed to the 
project using Linq_2-SQL and just query across databases
with one Linq query statement against 3 contexts.

If you don't want to do that, then use ADO.NET, SQL Command object, and 
a sproc.

Your other option would be to use ADO.Entity Framework, possibly using 
Entity-SQL.

0
Mr
5/7/2010 1:40:21 AM
Reply:

Similar Artilces:

If I want to buid a simple database for customer details, should I use Excel or Access?
I want to buid up a database for store detailed information of customers. The key words would be contained Customer's name, contact, visited time, email address links ( That can be easily used for sending emails). I wonder which program is better, Excel or Access? I am thinking that Excel is more common to use. And If I set up Excel, its data can be imported to Access. There are two clues here. The first is "database" - Access is the database application. The second is that, in spite of that, you fancy Excel, probably because you are more comfortable with Excel. It is yo...

Frx Reports to be use on other client machines without installing
Hi, I installed Frx as a thin clinet on my GP client machine and created Balance sheet and income statement reports successfully but now I want to run these reports on other clients machine without installing the Frx. Can u please tell me the correct way. Your immediate help will be greatly appreciated. -- Developer -- Bud Cool, Accounting System Manager HDA, Inc. Hazelwood, MO GP 9.0, SP2 "Dexdev" wrote: > Hi, > > I installed Frx as a thin clinet on my GP client machine and created Balance > sheet and income statement reports successfully but now I want t...

find record using combo box
I want to use combo box to locate a name. After update, the combo box shows the name but the form does not move to the record of combobox. Here is my code: Private Sub cboLook_AfterUpdate() Dim rs As DAO.Recordset 'Search in the clone set. Set rs = Me.RecordsetClone rs.FindFirst "[name]= """ & Me.cboLook & """" 'Display the found record in the form. Me.Bookmark = rs.Bookmark frmFlexSubform.SetFocus Set rs = Nothing End Sub You have a field named Name? Access ...

use screen captures to show icons etc
I can't find the send button in outlook, help has been useless, referring only to the button, not showing where it is. I would like help to use screen captures to show graphically the information they refer to. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http:...

GPIO read/write on intel using DDK example : Genport
Hi All, I would like to control one of the 14 GPIO provided on the Poulsbo UW15w. and I would like to use the driver (Genport) provided in DDK. Do you know if this would work to set and clear GPIO. How do I get the Address of the Port i want to set. (gpdwrite . ...) is it set in the .inf Thanks regards Norrih On Feb 16, 12:41=A0am, Norrih <Nor...@discussions.microsoft.com> wrote: > Hi All, > > I would like to control one of the 14 GPIO provided on the Poulsbo UW15w. > and I would like to use the driver (Genport) provided in DDK. > > Do you...

Error message when trying to use my access add-in with VS2008
I created a Access 2007 add-in with VS2008 C# and I'm trying to debug my access form that sends text to a textbox to be displayed after I click on a button. I can step into 'FillTextButton_Click()' in my C# app that gets called when I click on the access form button. So I have my button and textbox connected to Access2007 with the Access onLoad() event. Everything seems to be connected ok. But as soon as I finish running through the 'FillTextButton_Click()' I get a error message saying "The expression On Click u=you entered as the event property se...

XML to Database mapping
Hi folks! Has anyone out there come across a code generation tool that will do the following:- - read in a number of handwritten XSD files - create a set of SQL Server tables which can hold the same strctured data as the XSDs - create mapping code that will read individual XML docs compliant with the XSDs and insert the data into the database - create mapping code that will extract data from the database into compliant individual XML documents. My project will use about 200 xml schemas. Some elements will be commonly reused e.g. the Address element. Naturally, I would like these to b...

Combine Text from Multiple Cells
How do I combine text from mutliple cells into one cell? Hi Carter one option - well two really: if the information is in cells A1, B1 & C1 and you want it combined into D1 then in D1 type =A1 & " " & B1 & " " & C1 this will give you the contents of each with a space between OR =CONCATENATE(A1," ",B1," ",C1) which will give you exactly the same thing Hope this helps Cheers JulieD "Carter" <anonymous@discussions.microsoft.com> wrote in message news:5fc401c48ac0$9cc86830$a301280a@phx.gbl... > How do I combine tex...

where can I find the database schema?
and further info about what happens when a transaction occurs? I downloaded the sdk but didnt' see much in there regarding this. Anyone know? Thanks Hi Not sure you can, w/o the customisation guide - which is a closely guarded secret. If you are a strong database person the best thing to do is to run SQL Profiler that comes with SQL Server 2000. It will log pretty well everything that happens. You still will have to figure out the schema yourself but you will see what is going into what tables. JPH On Thu, 15 Feb 2007 04:59:39 -0700, D <Dave@nothing.net> wrote: ...

Multiple ADD COLUMN in one shot?
I have a statement in a query like: ALTER TABLE EXP ADD COLUMN first_name TEXT(75); If I wanted to add 5 columns in one shot, how would I do this? Trying to save this for repeatitive execution when I remove and recreate the primary table from the DB. Putting even 2 alter table statements in a row error. Guessing because this is a "Query", singular, and not a script but wondering if this is possible. Thanks. JR To get slightly better DDL facilities, use ADO or 'ANSI mode' instead of DAO or 'Access SQL' mode. Application.CurrentConnection.Execute("my DDL&...

still can't use Entourage, PowerPoint, Excel
I posted here several weeks ago and this problem couldn't be resolved then -- not entirely, anyway. I'm trying again because I haven't been able to find anything more anywhere else, and there WAS one thing I did right that I would like to duplicate -- plus, I'm pretty sure I can pinpoint when this problem started. When it started, I'm fairly certain, was when I downloaded the last Software Update of Office for Mac. This had to have been right around April 18, because I remember having downloaded the update late at night while I was working on something else, then rather th...

need help with tables so form okat- multiple equipment for 1 job
Here goes. I know this should be simple not sure why I can't see this right. Here is what I want to end up with not sure the best way to set up the tables to get what I want. and/or best way to create the form(from a query) or using form wizard pulling in tables that I need. I want to END up with a Form for all possible JOBS(cleaning jobs) with equipment needed and soaps needed for each job. There are many pieces of equipment for each job - mop, bucket, etc.(can't figure out how to get this in a form without listing with a comma) Have so far - don't thinks the tables a...

SQL Question
Can anybody decipher what this is trying to say? DECODE(SUBSTR(DISC_CD,1,3),NULL,' ','367','DNP','408','NIC','607','NIC',DECODE(FLOOR(ASCII(SUBSTR(DISC_CD,1,1))/60),0,'NIC','DNP') Examples of the disc_cd are 36712, 60706, etc.... Thanks, Mo -- Mo ----------------------------------------------------------------------- Moe's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1250 View this thread: http://www.excelforum.com/showthread.php?threadid=31984 Moe <Moe.1g6v7z@excelforum-nospam.com...

Can offset be used in this formula?
Can the offset be used in the below formula for the information in column "K"? In column L have the the following formula's L46 =MAX($I46*1000-$K$46*$J46,0) L47 =MAX($I47*1000-$K$46*$J47,0) .... L99 =MAX($I99*1000-$K$46*$J99,0) What I'd like to do is to copy the fomula into columns M, N, O, ... M47 =MAX($I47*1000-$K$47*$J47,0) M48 =MAX($I48*1000-$K$47*$J48,0) M49 =MAX($I49*1000-$K$47*$J49,0) .... N48 =MAX($I48*1000-$K$48*$J48,0) N49 =MAX($I49*1000-$K$48*$J49,0) .... O50 =MAX($I50*1000-$K$50*$J50,0) O51 =MAX($I51*1000-$K$50*$J51,0) .... How abou...

Save document to multiple locations
Other than repeatedly using Save As or Copy and Paste, is there a way to save a document to multiple locations? See the "Name" statement in help. As long as each file goes in a separate folder then... Dim OldName As String Dim NewName As String OldName = "C:\MyFolder\OldFile.xls" NewName = "C:\YourFolder\OldFile.xls" Name OldName As NewName Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware (Excel Add-ins / Excel Programming) "Bob" wrote in message Other than repeatedly using Save As or Copy and Paste, is there a way...

Place Access database into Word with styles?
I have an Access (2003) database with several tables. In one of these tables (let's call it "Books"), each row refers to a book. Fields include Title, Author, ISBN, CopyrightDate, Description, and so on. I also have a large Microsoft Word (2003) document containing documentation (let's call it "Reference") about a software product. I'd like to place the data from the Books table into the Reference document, but I want the benefit of the Word styles defined in the document so that I can customize the look of the exported info by using a Word style. For instance,...

Contact List in Address List for multiple user's
I created a Contact List in the Public FOlders. I want the list to appear in everyones Address List. How can I configure the Contact List to appear in everyones Address List without visiting each user's PC like through the Exchange System Manager, AD, GPO, etc? Thanks in advance. Greg In news:8AB85031-AE20-4CC9-B5D4-89556B7C5DC5@microsoft.com, Greg <gregkh@hotmail.com> typed: > I created a Contact List in the Public FOlders. I want the list to > appear in everyones > Address List. > > How can I configure the Contact List to appear in everyones Address > Lis...

Multiple servers for same doamin
Hello, I'm having a bit of a problem and everything points to an issue with first exchange server. I have 2 2003 servers, server A has my first exchange server running. Server B is new and has a new install of Exchange 2003. I setup a mailbox on Server B, but can't get any mail to and from it. Both servers are in the same routing group. Is there anything I'm missing? thanks! Sean On Mon, 04 Apr 2005 11:21:36 -0700, Sean Branam <sbranam@coronado.k12.ca.us> wrote: >Hello, > >I'm having a bit of a problem and everything points to an issue with >first exc...

Multiple Users receiving same account
This is a newbie question, but I can't think for the life of me. I want to setup 1 email address that will be received by 4 users. Do I set this up as a Group then add the users to that group? What kind of group? I don't want to have to go around and setup a pop3 account on each workstation. I know how to acheive this in Linux, but can't think how to do it in MS. Thank you everyone for helping I really appreciate it. Kevin Exchange versions would be helpful. You could set up a distribution list and add those four users to it. "Kevin" <Kevin@discussions.microso...

Using Webservice from VC++
Hi Everyone, I have a Visual C++ MFC program, and I am trying to use a webservice written in C#. When I add the webservice to my project using Add Web Reference the sproxy compiler complains about one of the object wanting to extend MarshalByRefObject object, and I get an error SDL1030. I can use the webservice in a C# project just fine but not the C++. Can anyone help me out with this? Thanks AliR. I also posted this message in microsoft.public.dotnet.framework.webservice but I am not sure if that was the correct newsgroup. There are way too many dotnet newsgroups out there. Hi Ali, ...

Using position() in XmlDataQuery
In Excel 2003 Professional, is it possible to do the following using XmlDataQuery - ie: use the "position()" function in the XPath: CType(ThisWorkbook.Worksheets(1), Excel.Worksheet).XmlDataQuery("/Doc/LineItem[position()=1]/Field") Where the XML in the map is: <Doc> <Stuff/> <MoreStuff/> <LineItem> <Field>FirstField</Field> </LineItem> <LineItem> <Field>SecondField</Field> </LineItem> </Doc> And have it return the cell for the "SecondField "? The XmlDataQuery...

Hiding Folders not being used regularly
How to hide folders that are not used daily. I work in an office where we have access to a number of folders, but I would like to hide the ones that I don't use regularly. Any suggestions? Use the Outlook Bar (for Outlook 2002 and previous) or the Shortcuts Navigation (Outlook 2003) to build your own Folder List structure with the folders you need. -- Roady [MVP] www.sparnaaij.net Microsoft Office and Microsoft Office related News Also Outlook FAQ, How To's, Downloads and more... Tips of the month: -Setting Permissions on a Mailbox -Create an Office XP CD slipstreamed with Serv...

Character that can be used for DeviceDesc
A commercial at (@) is used in our product name. I want to use the name for DeviceDesc of INF Sections without change. I could not find a rule whether we may use '@' character or not. Is '@' character allowed to use for DeviceDesc of INF Sections? Thanks Taka Taka <Taka@discussions.microsoft.com> wrote: > >A commercial at (@) is used in our product name. >I want to use the name for DeviceDesc of INF Sections without change. >I could not find a rule whether we may use '@' character or not. > >Is '@' character allowed to us...

Where is the "Connect to my Exchange mailbox using HTTP"?
Where is the "Connect to my Exchange mailbox using HTTP"? I'm trying to set up my Outlook client to use RPC over HTTP. The steps are: Create a profile Add a new email account, click next Click on Microsoft Exchange Server, click next Type the FQDN of the Exchange server, clear the Use Cached Exchange Mode checkbox Type the User Name, click on more settings (click cancel when it tries to resolve the name) In the Microsoft Exchange Server dialog box, click the Connections tab In this dialog box, I'm supposed to see a "Connect to my Exchange mailbox using HTTP" o...

Debit Cards and NOT using Citibank
We are in the process of trying to take debit cards and use ICVerify and First Data as our credit card processor. It wasn't until I did a test last night from RMS and researched the message I received that RMS only supports debit cards if you are using the built-in Citibank credit card processing. Is there anyway around this? If not, is RMS going to remove this restriction at some point? -- John M. You should be able to process debit cards by opening ICVerify and processing them directly. You would need to set up your debit card tender type in RMS as "Other". This isn...