0

I have 2 or more class:

public class AllParam
{
    public int Id { get; set; }
    public string Data { get; set; }
    public string Allarme { get; set; }

}

public class UtentiParam
{
    public int Id { get; set; }
    public string Utente { get; set; }
    public string Psw { get; set; }
    public string Livello { get; set; }
}

and I want to read data from my data base with this code:

var list = new List<AllParam>();

using (var db_ = new LiteDatabase(@"C:\HmiImpBroda\DataBase\" + TableToProcess + ".db"))
{
    var col = db_.GetCollection<AllParam>(TableToProcess);

    foreach (AllParam _id in col.FindAll())
    {
        list.Add(_id);
    }
}

Exist a way to set set AllParam or CurveParam in my function from a string? in this way I can use the same code for each type of class without write other code.

Thanks.

AbdelAziz AbdelLatef
  • 3,650
  • 6
  • 24
  • 52
  • If it is different tables or even different queries, you should have different classes and functions for each of them. What would you gain from having different queries with different results in the same function? – Christopher Nov 02 '19 at 20:08
  • I have around 50 db with different data type and I want different queries with different result in the same function. I'ts possible? In my dram i want to set one parameter and the function do the rest. – Fabio Bocchini Nov 02 '19 at 20:17
  • I have issues even thinking about how to make a single Database with 50 tables, much less 50 different Databases. Why are there 50? Why do they all mater for your programm? What do they contain? – Christopher Nov 02 '19 at 20:19
  • are all the data of my application that historicizes every single action and all the consumption of the raw materials I use. Currently everything runs on sql without problems but I realized that it is difficult to run sql in low-level systems and so I wanted to change direction. a query on sql is trivial but with litedb everything is much more complex. what do you suggest me? – Fabio Bocchini Nov 02 '19 at 20:48
  • So you want a [generic repository](https://stackoverflow.com/q/1230571/11683). It may not necessarily be the best idea. – GSerg Nov 03 '19 at 08:32
  • Onestly I don't know the best way to solve this problem.. I look for something similar to SQL but with more possibility for use it in tablet or something like this without the possibility to install sql 2016 – Fabio Bocchini Nov 03 '19 at 10:10
  • Maybe what you want is a distributed Database? Using a in-process/local DB to cache DB access on a Mobile device has to be the most commonly used pattern right now. It is used anywhere from your Mail App to your Postsmans device: https://en.wikipedia.org/wiki/Distributed_database – Christopher Nov 04 '19 at 12:01

0 Answers0