This is a migrated thread and some comments may be shown as answers.

Utilizing data virtualization with dynamic data

4 Answers 200 Views
Data Virtualization
This is a migrated thread and some comments may be shown as answers.
Austin
Top achievements
Rank 1
Austin asked on 30 Jan 2013, 10:25 PM
Hey,

I have a scenario where we do not know the column names or data types until run-time.

We would like to be able to use data virtualization in this scenario.  Basically we construct the sql statement at run-time once we query the table for its metadata (columns).  We could add an orderby, since the VirtualQueriableCollectionView needs one. 

The question is: without pre-loading everything from the table into the VirtualQueriableCollectionView (which would defeat the purpose of this view) how do we wire our sql statement into a VirtualQueriableCollectionView.

We studied this example: GridView -> Databinding -> Various Data Sources example -> Dynamic Data

This example solves the issue of dynamically generating columns that aren't hard-coded in a model, but doesn't show how one could hook this type of solution into data virtualization.

4 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 31 Jan 2013, 09:53 AM
Hello,

 I've made for you small example project which may help you to achieve your goal in your case. 

Regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Austin
Top achievements
Rank 1
answered on 01 Feb 2013, 02:55 PM
Hey Vlad,

Thanks for the sample project, it was very enlightening.  We have just run into one snag that we can't get around.  In our application we deal with a sql express / sql local db table that has a schema that is unknown until run-time.  Basically no solution that involves hard coding any kind of schema or model before compile time will work for us.

Thus, this notion of using the Entity Framework with a DbSet<tableSchemaClass> predefined will just not work for what we need. 

I've looked around on this site and ran into this:

=================================================

Run-time Schema Changes

The Schema Change API of Telerik OpenAccess ORM allows you to make runtime changes to the application's object model or database schema without recompilation of the application.

=================================================

This sounds similar to what we are interested in.  I guess what I am asking is if you can think of any other way to make this happen without using the Entity Framework since it seems to require some sort of hard-coded model.  Otherwise is there any way to make changes to an entity framework model at runtime?  (I was extremely unsuccessful at finding any information on that front)

I know delving into the entity framework is outside the realm of Telerik controls, but any info would be highly appreciated.

Edit-

After a lot of research and trying some strange things like creating a class at run-time via Reflection.Emit to use inside of DbSet I have realized that EF is simply not meant to work in this way.  The things it does with the model make this next to impossible.  I don't understand how such a simple concept as a database with a table with unknown columns can be such a huge hurdle.

 
0
Vlad
Telerik team
answered on 04 Feb 2013, 09:46 AM
Hello,

 I'm not sure if this is possible with EF however I believe you can use LINQ to SQL instead similar to this article to achieve your goal.  

Regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Austin
Top achievements
Rank 1
answered on 05 Feb 2013, 07:40 PM
Hey Vlad,

I'm not sure that article quite fits our use case.  I did some up with an idea though.  Basically it ends up looking like this:

                    items.ItemsLoading += (s, e) =>
                    {
                        List<Customer> list = new List<Customer>();
                        for (int i = e.StartIndex; i < e.StartIndex + e.ItemCount; i++)
                        {
                            Customer data = new Customer { ID = i + 1, Name = "Customer "};
                            list.Add(data);
                        }

                        items.Load(e.StartIndex, list);
                    };

Instead of using Linq here I just create my own list to pass to the items.Load function.  Since I don't have to use Linq I am not forced to have a static schema.  Thus I have the power to fill the list up in any way I want which I believe will solve my problems.  Thanks for all the input (that sample project was very helpful).
Tags
Data Virtualization
Asked by
Austin
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Austin
Top achievements
Rank 1
Share this question
or