在下面的注释掉的行中,PlatypusId是红色/无法识别的,尽管它确实存在于相应的表中.
在queryResult的多行跨越赋值中,PlatypusId,where和count是红色/无法识别的.
//var queryResult = await conn.Table<PlatypiRequested>().CountAsync().(x => x.PlatypusId.Equals(personId));
var queryResult = from p in PlatypiRequested
where p.PlatypusId.Equals(platypusId)
select count;
Run Code Online (Sandbox Code Playgroud)
IOW,当我添加这个:
var conn = new SQLiteAsyncConnection(SQLitePath);
var queryResult = await conn.Table<PlatypiRequested>().CountAsync().(x => x.
Run Code Online (Sandbox Code Playgroud)
......在"x => x"之后没有任何可能性被提供.
查询我的SQLite表需要什么样的代码?
我正在使用SQLite-net包/扩展,但它的文档(什么文档?)并不过分冗长.通过查看SQLite.cs和SQLiteAsync.cs,我不是更明智的......
好吧,Harvey先生的回答评论让我看到了这个工作代码(Count()不可用,只有CountAsync()):
public async Task<bool> PlatypusAlreadyAdded(string platypusId)
{
var conn = new SQLiteAsyncConnection(SQLitePath);
var queryResult = await conn.Table<PlatypiRequested>().Where(x => x.PlatypusId == platypusId).CountAsync();
return queryResult > 0;
}
Run Code Online (Sandbox Code Playgroud)
正如Jackie DeShannon(与我无关,AFAIK)演唱的那样,"现在世界需要的是一个"SQLite/SQLite-net for C#Windows Store应用程序"的书(或者至少是一篇冗长/内容丰富的博文,包含所有的例子)常见的SQL语句类型(CRUD)).
我目前正在为Windows 8编写一个Windows应用商店应用程序,我正在使用SQLite在Windows应用程序的类库中对嵌入式数据库进行持久化.我试图从我的嵌入式数据库中的两个不同表中加入数据,但SQLite不断从其GenerateCommand方法中抛出一个不受支持的异常.
我目前在两个表中都有数据,并且每个表中都有一个questionId可以加入.我尝试了两种不同的方法,它们都抛出相同的错误.
第一种方法:
var q = (from gameTable in db.Table<Model.GameSaved>()
join qTable in db.Table<Questions>() on gameTable.QuestionId equals qTable.QuestionId
select qTable
).First();
Run Code Online (Sandbox Code Playgroud)
第二种方法:
var q =
(from question in db.Table<Model.GameSaved>()
select question
).Join(db.Table<Questions>(),
game => game.QuestionId,
questionObject => questionObject.QuestionId,
(game,questionObject) => questionObject)
.First();
Run Code Online (Sandbox Code Playgroud)
我不确定我在这里缺少什么,但它必须是简单而明显的东西.
如果我使用SQL Server CE for Windows phone,我可以选择类映射到数据库表的哪些属性.这允许我在类上具有抽象属性.
例如
[Table]
public class MyClass
{
// this property is written to the database
private int _ItemId;
[Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
public int ItemId
{
get
{
return _ItemId;
}
set
{
_ItemId = value;
}
}
// abstract class. obviously this just an example. the real code checks for 11. =)
// under SQLite, it looks like this will …Run Code Online (Sandbox Code Playgroud) 我正在使用Sqlite-Net ORM,并希望从表中删除符合特定条件的所有行,例如:
conn.Table<MyEntity>().Delete(t => t.someProperty == someValue);
Run Code Online (Sandbox Code Playgroud)
有一些删除方法可以使用实体或主键.我现在当然可以获得符合我条件的所有实体,然后单独为每个实体调用delete,但这感觉不对.
目前我正在使用
conn.Execute("DELETE FROM MyEntitiy...")
Run Code Online (Sandbox Code Playgroud)
但我不喜欢这个版本.如果我重命名我的类,硬编码的SQL将不再起作用.
还有其他我错过的选择吗?
我在使用 Xamarin 的 PCL 中使用 Lync 语法。
public class settings
{
[PrimaryKey, AutoIncrement]
public int ID { get; set; }
public string user_name { get; set; }
public string password { get; set; }
public string server { get; set; }
}
void CreateTables()
{
database.CreateTable<settings>();
}
void Insert()
{
settings s = new settings();
s.server = "<none>"
s.user_name = "";
s.password = "";
database.Insert(s)
}
void Update()
{
settings s = database.Table<settings>().FirstOrDefault();
s.server = server_address.Text;
s.user_name = user_name.Text;
s.password …Run Code Online (Sandbox Code Playgroud) 我使用Sqlite构建了一个UWP应用程序.在我的本地机器上,我必须为通用Windows平台 Visual Studio扩展安装以下SQLite才能构建它.在UWP上使用sqlite时,我关注了这个博客
我现在正在尝试实现与Visual Studio Team Services的持续集成(Team Foundation Server Online).
我使用托管池来构建我的应用程序,但我收到以下消息:
C:\ Program Files(x86)\ MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(2049,5):错误MSB3774:找不到SDK"SQLite.UWP.2015,Version = 3.12.2".
它打破了构建.
如何在托管池上修复此问题?我没有物理访问机器,因为这是由TFS在线管理
编辑:
发现这是一个安装在我的本地机器上的库(通过Visual Studio扩展),因此我的托管计算机上不存在意味着引用被破坏我试图将相应的文件添加到源代码控制并直接从源代码引用它控制.但我不知道它实际上引用的是什么,因为它没有说.参考资料的属性如下:
鉴于我已经阅读了Xamarin关于本地数据库的文档,我只是对此感到好奇。
它sqlite-net-pcl是专为与XAMARIN?一起使用而设计的。我的意思是,如果他们都运行SQLite数据库引擎,那么假设我也可以使用System.Data.SQLiteNuGet 包是否安全?
SQLITE-NET-PCL NuGet Package
SYSTEM.DATA.SQLITE NuGet Package
会不会造成伤害?还是真的,而且只推荐使用这个sqlite-net-pcl插件?
希望有人能用这个来澄清我。
另外,我正在考虑Dapper ORM在我的Xamarin.Android项目中实现SQLite Database Engine. 我已经使这种方法适用于标准WinForm Apps. 所以也可以使用Xamarin.Android?
sqlite system.data.sqlite xamarin.android xamarin sqlite-net
I recently moved across from SQLite.NET to SQLite-net-pcl due to the Android 7.0 SQlite issue.
In the process I have updated all my libraries and all is working well with regards to insert/drop etc.
我唯一的问题是,每次从数据库中检索项目时,它的ID始终为0。这会导致更新项目的问题。有人遇到过这个问题吗?
[SQLite.PrimaryKey, SQLite.AutoIncrement]
public int ID { get; set; }
public string objectId { get; set; }
public DateTime createdAt { get; set; }
public DateTime updatedAt { get; set; }
public string Title { get; set; }
Run Code Online (Sandbox Code Playgroud)
提前致谢。
我有一个 Xamarin Forms 解决方案。我添加了 sqlite-net-pcl 作为所有项目的参考。它在 Android 上运行良好,但在 Windows 8.1 和 Windows Phone 8.1 上崩溃。我有一个 IOS 项目,但我目前没有 OSX 来尝试它。
我在 Windows 项目中使用它来访问数据库:
using System.IO;
using SQLite;
using Xamarin.Forms;
using HelloXamarin.Windows;
using Windows.Storage;
[assembly: Dependency(typeof(SQLiteDb))]
namespace HelloXamarin.Windows
{
public class SQLiteDb : ISQLiteDb
{
public SQLiteAsyncConnection GetConnection(string databaseName)
{
var documentsPath = ApplicationData.Current.LocalFolder.Path;
var path = Path.Combine(documentsPath, databaseName);
return new SQLiteAsyncConnection(path);
}
}
}
Run Code Online (Sandbox Code Playgroud)
以下是我的参考资料:
尝试访问数据库时出现此异常:
“SQLite.SQLiteConnection”的类型初始值设定项引发异常。
无法加载 DLL 'e_sqlite3':找不到指定的模块。(来自 HRESULT 的异常:0x8007007E)
我正在尝试使用最新版本的 sqlite-net-pcl nuget 包创建一个表
var db = new SQLiteAsyncConnection("data.db");
await db.CreateTableAsync<Site>();
Run Code Online (Sandbox Code Playgroud)
CreateTableAsync 调用引发以下异常:
System.MissingMethodException: '方法未找到:'System.String SQLitePCL.raw.sqlite3_column_name(SQLitePCL.sqlite3_stmt, Int32)'。'
这是站点类
public class Site
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public String Name;
public String PriceCssSelector;
public String URLRegex;
public Site()
{
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试降级到 sqlite-net-pcl 包的最新稳定版本。
sqlite-net ×10
sqlite ×5
c# ×4
xamarin ×4
azure-devops ×1
join ×1
linq ×1
tfs ×1
tfsbuild ×1
windows ×1