【发布时间】:2016-12-24 15:12:50
【问题描述】:
目前我在 sqlite 中存储图像(使用 ImageSource 元素)。在我尝试存储之后,我正在从本地目录中读取文件 图像到 sqlite 但我无法存储图像。谁能帮我储存。还如何将图像源转换为 xamarin.forms 中的字节
这是我的代码快照
Interface
Task<Product> AddToDo(string title, string subtitle,ImageSource img);
Calling method
ImageFile = ImageSource.FromFile("Chinese_6_600_C.jpg");
await azureService.AddToDo(Title, Subtitle, ImageFile);
public async Task<Product> AddToDo(string title, string subtitle, ImageSource img)
{
await Initialize();
var item = new Product
{
Title=title,
Subtitle=subtitle,
ImageFile= img
};
//TODO 5: Insert item into todoTable
await todoTable.InsertAsync(item);
//Synchronize todos
await SyncToDos();
return item;
}
这里我已经导入了 nuget 包 '( Microsoft.WindowsAzure.MobileServices.SQLiteStore)' 用于在 sqlite 和 azure 云存储之间存储数据。
当我将图像源插入' (await todoTable.InsertAsync(item)'时,它不接受。请帮助我处理这种情况
【问题讨论】:
-
stackoverflow 是针对明确定义的问题的具体、具体的答案,请参阅stackoverflow.com/help/on-topic。它不适用于像您这样的非常广泛的问题。开始编写您的应用程序,当您遇到特定问题时,请寻求帮助。通过简单地搜索xamarin forms save to sqlite,我找到了developer.xamarin.com/guides/xamarin-forms/working-with/… 和stackoverflow.com/q/26418449/3744182。
-
团队请接受我的问题。
标签: c# sqlite xamarin.forms azure-sql-database