命名空间 'SQLite.Net' 中不存在类型或命名空间名称 'Platform'

The type or namespace name 'Platform' does not exist in the namespace 'SQLite.Net'

我一直在研究我可以使用的数据库示例,我终于找到了一个,我正在尝试重新制定它,以便我可以在我想要的范围内使用它。

这是我正在使用的 link https://www.c-sharpcorner.com/UploadFile/f8fa6c/use-sqlite-net-in-xamarin-forms/

错误所在的代码:

namespace PAPvolley.Droid
{
    public class SQLite_Android : ISQLite
    {

        public SQLite.Net.SQLiteConnection GetConnection()
        {
            var filename = "Team.db3";
            var documentspath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            var path = Path.Combine(documentspath, filename);

            var platform = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();
            var connection = new SQLite.Net.SQLiteConnection(platform, path);
            return connection;
        }
    }
} 

我试图建立的连接:

public interface ISQLite
{
     SQLiteConnection GetConnection();    
}

我的数据库:

public class TeamDB
    {
        private SQLiteConnection _sqlconnection;

        public TeamDB()
        {
            //Getting conection and Creating table
            _sqlconnection = DependencyService.Get<ISQLite>().GetConnection();
            _sqlconnection.CreateTable<Team>();
        }

        //Get all students
        public IEnumerable<Team> GetTeam()
        {
            return (from t in _sqlconnection.Table<Team>() select t).ToList();
        }

        //Get specific student
        public Team GetTean(int id)
        {
            return _sqlconnection.Table<Team>().FirstOrDefault(t => t.Id == id);
        }

        //Delete specific student
        public void DeleteTeam(int id)
        {
            _sqlconnection.Delete<Team>(id);
        }

        //Add new student to DB
        public void AddTeam(Team team)
        {
            _sqlconnection.Insert(team);
        }
    }
public class Team
    {
        [PrimaryKey, AutoIncrement]
        public int Id { get; set; }

        public string TeamName { get; set; }
        public Team()
        {
        }
    }

您使用的代码在 sqlite-net-pcl 的最新版本中已过时。

要在 Android 项目中创建 SQLiteConnection,请安装最新的 sqlite-net-pcl 并执行以下步骤:

public class SQLite_Android : ISQLite
{

    public SQLiteConnection GetConnection()
    {
        var filename = "Team.db3";
        var documentspath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
        var path = Path.Combine(documentspath, filename);

        var connection = new SQLiteConnection(path);
        return connection;
    }
}

更多信息可以查看官方文档:databases and using-sqlite-orm