widget driven by SQL express

Topics: General, Writing modules
Jan 20, 2012 at 6:38 AM

thanks for your time ..

my goal: drive my ' widget' using an (existing) sql express db e.g. via a dropdownlist!

Reading the Orchard Docs and Discussions I'm not really clear where to start! But first some general questions:

A) when migrating (WEB matrix) the DBs from CE to express can I migrate per DB? It seems that always all are migrated .. which slows down the App a lot!

B) it seems that every time I use the it is tight to one record in the DB (Bing_Maps_BingMapRecord) ... how can I make this more dynamic?

C) I already have a MVC3 Razor app using BingMaps driven by a SQL express DB. Could I turn this existing Module into a Orchard part / widget?

where would I find some more documentation in this area?!

Thanks for your time and hints, ed





Jan 20, 2012 at 12:44 PM

You can create any arbitrary data table you like in Orchard. Define a SomethingRecord class with an Id, this record should not inherit from ContentPartRecord. Then create a migration for it. Finally inject an IRepository<TRecord> into your driver (or anywhere) and you have access to an IQueryable Table.

This is the best way to store additional data for your module, because you can do this all through Orchard's data layer and migrations.

Jan 21, 2012 at 6:08 AM

thanks for your time ...

I 'think' I understand your comment on the code centric approach for Data Access in Orchard. 

... obviously I have a 'blackout. What I'm missing is the link on how to make use of an existing SQL express DB. Where/how do I reference my ConnectionString which points to a remote server?

Can I use at all a ConnectionString (WEB.config)!?

apologies for my ignorance

thanks for your time, ed  

PS: I'm just starting to learn the great Orchard!

Jan 21, 2012 at 11:16 AM

You set your connection string when you first install Orchard, it's right there on the install form. This gets saved in a Settings.txt file in a App_Data\Sites\Default.

Jan 21, 2012 at 11:18 AM

Oh I see ... if you absolutely need an external DB then you have to go through a lot more work. You'll have to implement Site Settings to store your unique connection string, and then write your own data access code. It's a lot of work; can't you just model your data within Orchard's framework and then copy it across from your external DB? It'll be way easier...

Jan 21, 2012 at 1:18 PM

thanks again for your time .... after digging a bit more I found the Settings.txt file!

At least to start I'll take your advise and stick to Sql CE /Orchard! ... and probably stick with it!

 ... because, at the very beginning I started an Orchard project setting my SQL express string and it got veeery slow; so I thought I leave the Orchard DBs on CE and use only my own DB on express?!  But this would make it probably even more complex ...!

A) are there any special considerations when copying SQL express to CE? can the WEB matrix DB migration do that? 

B) Is there anywhere a sample I could use to start with!? of course I'll take your advise you made earlier in this thread!

thanks again, ed