Santiago Vasquez
Santiago Vasquez

Reputation: 175

Xamarin Cannot compile: Parameter System.Collections.Generic.List`1[T] queryArgs

I have a problem with a query of SQLite Xamarin

I have installed sqlite-net-pcl 1.7.335 and SQLiteNetExtensions 2.0.0

The process of error is the next:

I fill the variable nuevoRegistro: enter image description here

dataService.InsertOrUpdate<PointOfSaleDTODBModel>(nuevoRegistro);

My model PointOfSaleDTODBModel:

enter image description here

I call the method and send it the variable nuevoRegistro

    public T InsertOrUpdate<T>(T model) where T : class, new()
    {
        try
        {
            var oldRecord = DataAccess.GetInstance().Find<T>(model.GetHashCode(), false);
            if (oldRecord != null)
            {
                DataAccess.GetInstance().Update(model);
            }
            else
            {
                DataAccess.GetInstance().Insert(model);
            }

            return model;
        }
        catch (Exception ex)
        {
            ex.ToString();
            return model;
        }
    }

In this step is where i have the problem

    public T Find<T>(int pk, bool WithChildren) where T : class, new()
    {
        return connection.Table<T>().FirstOrDefault(n => n.GetHashCode() == pk);
    }

The error that get is the next:

enter image description here

Error Text:

Any help, thanks you

Upvotes: 1

Views: 192

Answers (1)

ColeX
ColeX

Reputation: 14475

Here are some suggestions for your code , it may solve the problem .

  1. Use SQLiteAsyncConnection instead of SQLiteConnection , refer to official docs .

  2. Use Id instead of HashCode to get data .

    Database.Table<TodoItem>().Where(i => i.ID == id).FirstOrDefaultAsync();      
    

Upvotes: 1

Related Questions