【问题标题】:Are there any ORMs that support SQLite for Universal Apps?是否有任何 ORM 支持通用应用程序的 SQLite?
【发布时间】:2014-07-22 17:27:36
【问题描述】:

这就是问题所在。我听说 EF7 将支持 Windows Store 和 Windows Phone 的 SQLite,但现在有什么交易?是否有任何其他 ORM 支持通用应用程序上的 SQLite?

【问题讨论】:

    标签: sqlite orm windows-store-apps windows-phone-8.1 win-universal-app


    【解决方案1】:

    CoolStorage,但我对那个 ORM 没有任何经验。

    本身不是 ORM,但请查看 SQLite.NetSQLite.Net Extensions。 我现在正在一个通用应用程序中使用它,它可以满足我的需要。

    请注意这里有not yet support for relations in LINQ

    我自己目前正在使用这样的扩展:

    public class Bar
    {
        [PrimaryKey, AutoIncrement]
        public int Id { get; set; }
    
        public string Title { get; set; }
    
        [ManyToMany(typeof(FooBar))]
        public List<Foo> Foos{ get; set; }
    }
    
    public class Foo
    {
        [PrimaryKey, AutoIncrement]
        public int Id { get; set; }
    
        public string Title { get; set; }
    
        [ManyToMany(typeof(FooBar))]
        public List<Bar> Bars{ get; set; }
    }
    
    public class FooBar
    {
        [ForeignKey(typeof(Foo))]
        public int FooId{ get; set; }
    
        [ForeignKey(typeof(Bar))]
        public int BarId{ get; set; }
    }
    

    【讨论】:

    • 这很令人失望,这就是我实际追求的,避免编写sql查询。这似乎是不可能的,好吧。
    • @Pantelis 查看我对 CoolStorage 的编辑。也许你可以试试那个。
    • 我以前见过,但没用过。我没有看到任何地方提到 Windows Store Apps。这实际上已经很老了,它适用于 Windows Phone 7。
    • @Benjamin Diele 我无法在 Universal 应用程序中使用 sqlite.net 扩展,因为它没有安装在我最后的 windows phone 项目中。你能分享你的解决方案吗?
    • @MuhammadSaifullah 我克隆了 SQLite.Net 存储库并添加了普通 (PCL) 版本。之后我克隆了 SQLite.Net 扩展并添加了它。我认为不需要克隆 repos,但我发现它更容易,以便在出现问题时可以运行源代码。如果您需要应用示例,请告诉我。
    猜你喜欢
    • 2016-04-17
    • 2014-06-16
    • 1970-01-01
    • 2011-03-03
    • 2010-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多