3

I am following the instruction at http://msdn.microsoft.com/en-CA/library/hh361039.aspx to perform database queries.

I would like to join tables from different databases(same instance). The example in the tutorial

SqlMetal.exe /sprocs /dbml:C:\destpath\MyDatabase.dbml /server:SERVER\INSTANCE /database:MyDatabase

does not provide such option.

Can this be done with F# or I have to use different tool set(C# + dapper) to achieve what I want?

Wei Ma
  • 3,125
  • 6
  • 44
  • 72
  • The vast majority of these tiny DAL applications use a single database. Joining tables from two different databases is almost certainly out of scope for Linq to SQL or Dapper. However, you might find some clues on how to do it here: http://stackoverflow.com/q/1910981 – Robert Harvey Apr 18 '13 at 22:23
  • Actually, dapper is capable to do what I want. But it's not that easy to make dapper to work with F#. – Wei Ma Apr 18 '13 at 22:26
  • @WeiMa why not? Dapper is single C# class (if not use extensions). You can build it ito assembly and use from F#. However there is no out of box F# type provider which uses dapper. – petro.sidlovskyy Apr 19 '13 at 06:15
  • @petro.sidlovskyy The reason is that I am not sure how to handle the "dynamic" equivalent in F#. And dapper heavily depends on it. I know there are tutorials for this, but I feel much more comfortable with C# if I have to use the "?" operator in F# – Wei Ma Apr 19 '13 at 18:40
  • @petro.sidlovskyy Yeah, maybe I can try to build dapper into a dll and use it as black box, but I doubt it will work. – Wei Ma Apr 19 '13 at 18:42
  • @WeiMa : Here are some good answers on using the DLR from F#: http://stackoverflow.com/q/5057672/636019 http://stackoverflow.com/q/6150087/636019 – ildjarn Apr 19 '13 at 22:08

2 Answers2

0

Maybe Tranq is the way to go. I will give it a try for my next project.

Wei Ma
  • 3,125
  • 6
  • 44
  • 72
0

I don't think Entity Framework will let you span multiple databases; however if it's only for a small amount of data, you could possibly rig this by having a View in the main database that selects data from the other database.

Danny Tuppeny
  • 40,147
  • 24
  • 151
  • 275