I need to Query existing Tables inside my Orchard database. These tables are coming from an existing ecommerce website. So my question is: How do I query tables that contain data inside my Orchard database and have the data displayed on the Admin/Editor side. And finally on the front end/user side when the page is published? I have All the Models, Drivers, Handlers and Views created. I'm just stumped on where to Query the DB.
You can inject an IRepository and do queries on its Table. If that is still too high level, you can inject an ISessionLocator and call For on it. The session object it will give you is the nHibernate session, on which you can perform arbitrary queries.
Related
I am developing a system with a master database and multiple databases, once for each client. The client database and its tables will be created when the client fills in and submit a form with all the required details.
My question: does the Yii framework support the dynamic creation of databases and tables? If so, is there any example code? (I'm still learning about Yii) I couldnt find an answer on the Yii website (documentation and forum) nor on this site. (I did notice that dynamic databse connections are possibble with Yii - Yii Dynamic DB Connection according to user?)
For connections in runtime read php-yii-database-connect-in-runtime and after that, Yii have all Building Schema Manipulation Queries like CREATE, ALTER, DROP etc.
So easy and simple.
building-schema-manipulation-queries
My MVC 4 application is using Entity Framework 5 as its ORM.
And an Oracle 10 database is used as its back-end.
MVC Views are displaying data from Oracle DB Views, and I have no control over database schema.
The Views are updatable, and there is also a requirement of managing concurrency. There is no timestamp sort of column in the underlying table/ view.
In such scenario, how can I manage concurrency?
Any advice on this will be much appreciated.
Sorry for the late answer but I just came across this.
As you have no access to the database, it would not be easy at all to prevent 2 users from requesting edit on the same record (even if you did, I am not sure there is a bullet proof way of doing this in a web application). What you can do is prevent a user from editing an object that was modified between the time it was retrieved and the time of change submission. I am going to assume that in your MVC application you are using view models to represent the domain model objects on the screen. You can include as an additional field in the view model a field for a hash computed based on the state of the object at time of retrieval. When an edit is posted, you would need to retrieve the record again from the database, compare its current hash with the one submitted by the MVC view. In case of discrepancy, inform the user of change and show the values as they are now in the database informing the user of what happened (e.g. by adding a model state error).
I have a SQL view to integrate with my application. I have been using Entity Framework till now. But the problem is that when I add a view to Entity Framework it starts treating my view as a table.
What I really want to know is, am I missing on something? Also if I use Nhibernate will this problem be resolved? Will it treat the view as a view only?
This view is a very complex query which has multiple joins and aggregation. That is why I am using a view.
But the problem is that when I add a view to Entity Framework it
starts treating my view as a table.
No it doesn't. If you add view to your model through wizard (EDMX designer) it will internally handle the view as a defining query which makes readonly entity. At entity level (the conceptual model) you don't see a difference because it is just another entity / class but if you try to make changes to instance of that class and save them you will get an exception (unless you map stored procedures or custom SQL commands to insert, update and delete operations for that entity).
Edit:
Database views as well as other database specific features like stored procedures or SQL functions are only for database first scenario (when you are using Update model from database in the designer).
Using Generate database from model is for Model first scenario where you tell VS: "Here is my model and I want some database to store it." First of all only information from conceptual model is used (original mapping and database description is replaced with a new one every time you run this command so even mapping to original database can be broken). It cannot create database specific features for you because it doesn't know that class should be mapped to view and moreover it doesn't know how should the view be created (the query from original view is unknown).
You can force VS to create the view for you but it is a lot of work in T4 templates where you will have to somehow provide SQL creation script for the view.
We are working on a sync application using ColdFusion 9.0.1 ActionScript ORM Library for AIR applications. Since this is application should work smoothly offline as well, there is a list of clients that has to be loaded when a user logs in, hence we are fetching data from all the required tables when application loads (is that the right way?). Now when we get the data from the required tables then based on the user who logs in we have to filter the clients, to filter this the query required is a complex one with joins between 5-6 tables and where clause. What I found that using the Coldfusion.Air.Session class we can only load objects of tables with simple where clause. There is non ORM way to load the data but I don't think that is the right method. Is there any method using this ORM framework to load data using such complex queries.
Thanks,
Gaurav
Are you using any CF code to send data back to your application? Have you tried HQL?
In other words you can write standard cfquery and dbtype="hql"
This will let you do almost anything you can do with a standard cfquery.
I am not directly familiar with the ActionScript ORM Library for AIR.
I'm working on an application that has a data publication mecanism that I designed & implemented. It allows one master instance of the app to feed data to many subscriber instances. This is implemented by loading the master's data into a set of temporary import tables that have the same exact schema on the subscriber. The merge process uses these import tables to do its work.
This whole publication thing is working fine. It is performed outside of NHibernate using ADO.NET for batch loading, sets of stored procedures for diff'ing & merging (they're autogenerated by a custom tool). Also, we only have an HTTP link available between master/subscriber to download the data; we can't connect directly to the master SQL server.
The problem I face is visually showing the diff to the user before they actually merge the new data. In the application, I'd like to have NHibernate load our business object directly from these temporary import tables.
Can we do this ? Without having to maintain two sets of almost identical mapping files ?
In our last version, we were building up business objects using custom code that would load from these import tables. It would only load simple properties, not handling relations. This sucks big time from a coding/maintenance point of view.
Are you trying to do something like this where you need to dynamically change the table names?
You may also want to look at Fluent NHibernate for a solution.
Another possibility would be to have the temporary tables in a separate database and just change the connection string.