当执行对xamarin表单pcl的查询时,没有这样的表sqlite

时间:2022-10-18 22:58:23

I have a problem with the reading of the tables on the SQLite database.

我在读取SQLite数据库上的表时遇到了一个问题。

my OBJ_User class:

我的OBJ_User类:

    namespace Fimap.Models
{
    public class OBJ_User
    {
        public int DLR_Id { get; set; }
        public string DLR_Username { get; set; }
        public string DLR_Password_Hash { get; set; }
        public object DLR_Nome { get; set; }
        public string DLR_Cognome { get; set; }
        public int DLR_Tipo { get; set; }
        public string DLR_Azienda { get; set; }
        public object DLR_Telefono { get; set; }
        public object DLR_Email { get; set; }
        public int DLR_Abilitato { get; set; }
        public object DLR_Time_Zone { get; set; }
        public object DLR_Country { get; set; }
        public string DLR_Culture { get; set; }
        public object DLR_Email1 { get; set; }
        public object DLR_MCC_Modello_Alias { get; set; }
        public object DLR_Anagrafica { get; set; }
        public object DLR_Firma { get; set; }
        public bool IsFIMAP { get; set; }
        public bool IsSTANDARD { get; set; }
        public bool IsDealerOrFimap { get; set; } //true dealer - false user
        public object DLR_Tipo_Esteso { get; set; }
        public object DLR_Abilitato_Esteso { get; set; }
    }
}

my interface in pcl project:

我在pcl项目中的界面:

public interface IDatabaseConnection
    {
        SQLite.SQLiteConnection DbConnection();
    }

Android

安卓

[assembly: Xamarin.Forms.Dependency(typeof(DatabaseConnection_Android))]
namespace Fimap.Droid
{
    public class DatabaseConnection_Android : IDatabaseConnection
    {
        public SQLiteConnection DbConnection()
        {
            var dbName = "FimapDB.db3";
            var path = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), dbName);
            return new SQLiteConnection(path);
        }
    }
}

iOS

iOS

[assembly: Xamarin.Forms.Dependency(typeof(DatabaseConnection_iOS))]
namespace App.iOS
{
    public class DatabaseConnection_iOS : IDatabaseConnection
    {
        public SQLiteConnection DbConnection()
        {
            var dbName = "FimapDB.db3";
            string personalFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            string libraryFolder = Path.Combine(personalFolder);
            var path = Path.Combine(libraryFolder, dbName);
            return new SQLiteConnection(path);
        }
    }
}

pcl connection (database is right connect):

pcl连接(数据库为右连接):

database = DependencyService.Get<IDatabaseConnection>().DbConnection();

当执行对xamarin表单pcl的查询时,没有这样的表sqlite

query:

查询:

var test = database.Query<OBJ_User>("SELECT * FROM OBJ_User");

when i launch the query i have this error:

当我启动查询时,我有以下错误:

SQLite.SQLiteException: no such table: OBJ_User

SQLite。SQLiteException:没有此类表:OBJ_User

当执行对xamarin表单pcl的查询时,没有这样的表sqlite

OBJ_User is in the dabatase with one record. Why the connection don't mapping the table ? database variable is right connect to database sqlite, i don't understand because database don't get mapping from sqlite file. Solution ?

OBJ_User有一条记录。为什么连接不映射表?数据库变量与数据库sqlite的连接是正确的,我不理解,因为数据库没有从sqlite文件获得映射。解决方案吗?

if you want other info write me in the comment, i will answer

如果你想要其他信息,请在评论中留言给我,我会回答

1 个解决方案

#1


2  

The SQLite library doesn't know how to map the properties of type object to a sqlite column. The SQLite library supports the following column types by default: string, int, double, byte[], DateTime.

SQLite库不知道如何将类型对象的属性映射到SQLite列。SQLite库默认支持以下列类型:string、int、double、byte[]、DateTime。

#1


2  

The SQLite library doesn't know how to map the properties of type object to a sqlite column. The SQLite library supports the following column types by default: string, int, double, byte[], DateTime.

SQLite库不知道如何将类型对象的属性映射到SQLite列。SQLite库默认支持以下列类型:string、int、double、byte[]、DateTime。