Back to
Latest changes:
2020/01/13 19:15

This is an old revision of the document!


Building data model dynamically by DB meta-information

You can avoid creating a data model XML file through Data Model Editor utility and fill your model right in the code directly from your database (or more precisely: by its meta-info).

To perform this task you just need to create an appropriate instance of DbGate class (depending on DB and connection type you use), connect it to your database and call FillByDbGate() method of DbModel.

Here is an example:

    //clear current model
    model.Clear();
 
    //add default operators
    model.AddDefaultOperators();
 
    //create DbGate instance (this one is for SqlConnection, you can use also OleDbGate, OdbcGate, OracleGate, etc).
    Korzh.EasyQuery.DataGates.SqlClientGate sqlGate = new Korzh.EasyQuery.DataGates.SqlClientGate();
 
    //connect DbGate object to your database
    sqlGate.ConnectionString = @"Data Source=localhost;Initial Catalog=NWind;Integrated Security=True";
    sqlGate.Connected = true;
 
    //fill the model
    model.FillByDbGate(sqlGate, FillModelOptions.Default);
 
    //update visual controls        
    queryPanel1.UpdateModelInfo();
    columnsPanel1.UpdateModelInfo();

Please note: To create some DbGate object (like SqlClientGate) will need to add a corresponding assembly into the “References” section of your project. For example to execute the code listed above you will need to reference Korzh.EasyQuery.DataGates.NET40.dll assembly.

Discussion

, 2013/10/25 09:50
How we get this assembly Korzh.EasyQuery.DataGates.NET40.dll to add in my Project.
, 2013/10/25 12:58
If you already installed EasyQuery you will find this DLL in <install dir>\Korzh.NET\assemblies\NET40

For default settings it is:
C:\Program Files\Korzh.NET\assemblies\NET40
, 2013/10/28 09:12
I have a Problem when I try to add join between two tables .I get this error
"Cannot find a path between tables ‘XYZ’ and ‘VSY’ ".
How can I remove this Error???
, 2013/10/30 13:12
This error mean that your data model does not contains a "path" between these two tables - so there are no link from table XYZ which (maybe through some other tables) finally leads table VSY.
, 2014/07/18 11:49
How can I create queryPanel1 and columnsPanel1?
, 2014/07/18 12:29
//update visual controls
queryPanel1.UpdateModelInfo();
columnsPanel1.UpdateModelInfo();
, 2014/07/18 23:44
Usually these controls are placed on your form (either WinForms or WebForms).
In case of MVC project these lines are not necessary since visual controls in that version are running on client-side as JavaScript widgets.
, 2014/07/21 09:08
Hello!
I am going to make EasyReporting. But I have not any example EasyReporting for ASP.NET MVC.
, 2014/07/21 09:21
You mean that EasyReporting demo is not included into trial version of EasyQuery ASP.NET?

You are right - we didn't included it yet because it's not finished.
I can send current version to you by email if you would like.
, 2014/07/21 09:23
Ok.
Please, send me!

-------
Thanks!
, 2014/07/21 10:10
OK. In a few hours.
, 2014/07/22 07:04
Hello!
When do you send EasyReporting demo for ASP.NET MVC?
I wait...
, 2014/07/22 09:19
I've already sent it to the email indicated in your profile here: luckyprog13@gmail.com
Is it correct address?
, 2014/07/22 10:16
Yes it is correct address.
Thanks!
I get your message.
, 2014/08/26 13:02
What is EasyReporting for ASP.NET MVC? I would like to have it, too. Could you send to me? Thanks, Henry Felipe.
, 2014/08/26 13:57
EasyReporting is a sample project which demonstrates how you can use EasyQuery library to create a simple solution for ad-hoc reporting.
Here is the live demo: http://demo.easyquerybuilder.com/ad-hoc-reporting/

The source code for this demo is included into trial version of EasyQuery which you can download here:
http://devtools.korzh.com/easyquery/
Enter your comment: