[英]Entity Framework and Linq equivalent in Android
I am new to Android. 我是Android新手。 I literally just learn Android few days ago. 我刚从几天前开始学习Android。 I am just wondering, is there Entity Framework and LINQ equivalent for Android? 我只是想知道,是否存在Android的Entity Framework和LINQ等效产品?
Also, I need to store/cache record to a local database. 另外,我需要将记录存储/缓存到本地数据库。 What the best database to use? 什么是最好的数据库? I am thinking of using SQLite. 我正在考虑使用SQLite。 Is it appropriate for Android? 它适用于Android吗?
Thanks! 谢谢!
You need an ORM(Object-Relational Mapper), there is a good cross platform ORM called Realm , Realm gives you a much more programmatic way of accessing and storing data in Objects just like LinQ or EntityFramework and executes queries pragmatically in an object oriented manner. 您需要一个ORM(Object-Relational Mapper),有一个称为Realm的跨平台ORM,Realm为您提供了更多的编程方式来访问和存储对象中的数据,就像LinQ或EntityFramework一样,并且以面向对象的方式务实地执行查询。
Sample Realm Code 领域代码示例
RealmResults<User> result = realm.where(User.class)
.greaterThan("age", 10) // implicit AND
.beginGroup()
.equalTo("name", "Peter")
.or()
.contains("name", "Jo")
.endGroup()
.findAll();
SqLite is appropriate to store local Data for example: if you are retrieving JSON, u can us an sqlite database to store some data for the offline mode, and of course u can use the cache as well, but i recommend u SQLite. SqLite适合存储本地数据,例如:如果您要检索JSON,您可以使用sqlite数据库存储脱机模式下的某些数据,当然您也可以使用缓存,但是我建议您使用SQLite。
Hope i helped. 希望我能帮上忙。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.