locked
Dynamic query in windows store apps

    Question

  • I am creating an windows store app. and i'm using sqlite + sqilite-net class from nuget packages. I need to make a query via reading data from table i.e. table name and field name that i require to make a query is stored in database so i need to fetch those data from table and make a query. I am creating dynamic layout where control label, type, itemsource are all stored in database and i need to create layout from those. 

    I tried from my side but didn't find any way in which i can assign table name and field name from variable or other object. and can access those retrieved values from the same variable storing table name and field name

    Any help would be really appreciated...

    Thursday, November 13, 2014 11:46 AM

Answers

  • Hi Purushottam,

    It seems like a lambda question. Does you mean the ResearchGroup, ResearchGroupCode, FieldValue and ResearchGroupName are all variable? If so, I would recommend you take a look at Lambda Expression tree. This can help executing a dynamic Lambda. http://msdn.microsoft.com/en-us/library/bb882637.aspx

    If i misunderstand you, please feel free to let me know.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Saturday, November 15, 2014 3:14 AM
    Moderator

All replies

  • Hi Purushottam,

    Sqlite-net is a wrapper that provides many classes can help to achieve your goal. Based on my understanding, you want to get table schema to create a dynamic layout. The TableMapping class give you the opportunity to retire the schema of the table. Using the following code.

    var db = new SQLiteConnection(localPath);
    
    TableMapping ColumnDefinition = db.GetMapping<Customers>();
    

    When you get the column definition, it contains column name, column data type and so on. You can see details in SqLite.cs file.

    If I misunderstand you, please feel free to let me know.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Friday, November 14, 2014 3:13 AM
    Moderator
  • I have to fetch table name and field name from database. i.e

    if i ve to make query it will be like this

    using (var db = new SQLiteConnection(App.dbPath))
     {
         var research = db.Table<[ResearchGroup]>().Where(r => r.[ResearchGroupCode] == _filter.[FieldValue]).FirstOrDefault();
                            _filter.DescField = research.[ResearchGroupName];
                        }

    Here _filter is an object.

    Since it is full dynamic , all the values that i put inside bracket [] are either stored in database or in any value, and i cant replace those value inside bracket by some local variable

    Friday, November 14, 2014 3:55 AM
  • Hi Purushottam,

    It seems like a lambda question. Does you mean the ResearchGroup, ResearchGroupCode, FieldValue and ResearchGroupName are all variable? If so, I would recommend you take a look at Lambda Expression tree. This can help executing a dynamic Lambda. http://msdn.microsoft.com/en-us/library/bb882637.aspx

    If i misunderstand you, please feel free to let me know.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Saturday, November 15, 2014 3:14 AM
    Moderator