I have 2 different SQL Server databases which cannot be combined as one of them is a vendor db. Aside from creating a view in SQL server with linked databases, is there a way to use fluent api or something in entity framework to perform simple joins between tables between the two databases?
Apparently this will is how its done.
http://www.c-sharpcorner.com/UploadFile/ee01e6/how-to-join-two-tables-from-different-database-using-entity/
Related
Does anyone have experience building database reports - doesn't matter which database - i just want design ideas - for a system that is made up of many separate, but identical databases?
I cannot "combine" all databases into one. They must be separate.
But the structure is identical across all databases...
I need to build a web interface that will allow a user to get a "global" report that will query all databases and build one combined report.
Do you have any comments on how the model would look like? or anything you think i need to beware of?
Thanks.
I don't have first hand experience with cross database reports, my experience comes from a product the company i work for sells which can create reports from multiple databases, from your description i believe you require something of the "combine" tables kind, in this case i recommend you to detect the tables used in the query, and unify them in a single temporary intermediary database, for example Access, SQL Server CE or SQLite and then run the query against this temporary database or table.
If your databases are Microsoft SQL Server, then using SQL Server Reporting Services seems like a good solution. The software for the report generation / display is bundled along with the database software.
It gives you a web interface, where you can configure 'data sources' from any number of remote databases, and combine data from these sources into reports. It is user friendly and you can do all the report design / configuration through the web interface without having to write any code.
some references :
Building report using SQL Server stored procedure
http://blog.hoegaerden.be/2009/11/10/reporting-on-data-from-stored-procedures-part-1/
I am investigating for different ORMs to use in a new Web Application I have to develop.
I hesitate between NHibernate and EntityFramework 4.1.
I know that NHibernate does support different databases (like SQL Server, MySQL, Oracle, and so on.) isn't it?
What about Entity Framework? I cannot find which databases it supports (I suppose it is database agnostic but I am not very sure). For example, I was not able to make it run with MySQL (with MySQL Connector 6.4.3).
The answer I want is only regarding on the support of differents databases. There are some information in stackoverflow about "NHibernate vs Entity Framework".
Entity Framework query is translated into final form (sent to DB) by three "layers":
1. Object Services
2. EntityClient Data Provider
3. ADO .NET Data Provider.
The Object Services layer is a component of the Entity Framework that enables you to
query, insert, update, and delete data, using common language runtime (CLR) objects that
are instances of entity types.
The Entity Framework includes the EntityClient data provider, which manages connections, translates entity queries into data source-specific queries, and returns a data reader the Entity
Framework uses to materialize entity data into objects.
Traditional ADO.NET is still used to communicate to the underlying database.
What does it mean? It means Entity Framework was designed to be database independed. You can use it with every database if database provider has created provider for ADO .NET (which exists for MySQL, Oracle etc.).
For MySQL you should be able to use EF with connector that you've mentioned (more info: http://dev.mysql.com/doc/refman/4.1/en/connector-net-visual-studio-entity-framework.html)
Out of the box NHibernate supports following:
Microsoft SQL Server (including Compact Edition)
Oracle
Microsoft Access
Firebird
PostgreSQL
DB2 UDB
MySQL
SQLite
Corresponding ADO.NET provider needs to be installed. In addition to ADO.NET provider, NHibernate needs its own 'driver' and 'dialect' if you want to extend it to support the database that is not on the list.
I'm relatively new to .NET but I'm trying to determine if it's possible to have a single .NET 4 application connect to multiple vendor databases simultaneously (SQL Server, Oracle, DB2 and MySQL) using ADO.NET and execute queries simultaneously?
All the examples I've found so far talk about connecting to only one database at a time.
Thanks!
You just need 4 connections strings and 4 separate ADO Connection objects. And then what SLaks said about async queries to do them simultaneously, if you truly want them running in parallel.
You can execute two queries the same way you execute one query.
If you want them to execute two queries at once, you'll need to make asynchronous queries or use threads.
The ADO.NET framework defines an abstract set of 'DbXXX' classes like DbConnection,DbCommand etc, which are implemented by various database providers such as
System.Data.SqlClient.SqlConnection' in the System.Data.dll for Sql Server
'Oracle.DataAccess.Client.OracleConnection' in the Oracle.DataAccess.dll (ODP.NET provider) for Oracle
'MySql.Data.MySqlClient.MySqlConnection' in the MySql.Data.dll for MySql etc
You then need to design your apllication against the abstract set of classes and use appropriate implementations wherever required. Most of the queries should work against all the backends but there will obviously be backend specific tweaks, not to mention stored procedure calls.
Alternatively you could use an ORM (Entity Framework, Telerik OpenAccess ORM, NHibernate etc) and abstract much of this difference to the ORM. Although I am not sure you can use a single entity model (in EF) against multiple backends.
What is the best way to create Sql Server tables from business objects. For example I'm writing an application that has a user object to store user information. What's the best practice for creating tables from these objects? Create the objects first and then define the database or is there a tool to transform business objects into tables?
I'm just curious how others are doing this type of task.
Use an ORM (object-relational mapping) tool, a list for tools for several languages can be found here: http://en.wikipedia.org/wiki/List_of_object-relational_mapping_software
We are using NHibernate. It allows to write classes first, map them to the database by configuration (mapping files) and generate the database tables from that. It also allows restructuring the database (eg. for optimization) without touching business logic at all.
Of course, you still need to care about existing databases (schema migration).
There may be other ORM which have similar functionality. NHibernate is one of the most powerful.
Little background: I'm working in a large company with a lot of branches. We have several applications with separated databases sometimes on different servers. But every database contains a table with a list of branches and their relationships. I want to automatically synchronize these tables when one of them changed.
My question is: what are the best practices of automatic synchronization of tables in different databases (Microsoft SQL Server 2008)?
Are there sql server features for that purpose? Or external tool is a good way? Or it's better to write a small application and run it as a service or use the scheduler?
You can use replication (a SQL server built-in feature) to synchronize different databases.
You can also use triggers or log shipping to sync your tables as records are added ,updated or deleted:
Here are some links about replication.
Here are some links about log shipping.