我想将使用ORMLite的Android代码库转换为它的C#等价物,用于使用SQLite-net PCL nuget包的Xamarin.Android。C#相当于Java代码片段Xamarin.Android
的Java:
public abstract class DTAbstractEntity {
}
import entities.DTAbstractEntity;
import com.j256.ormlite.field.DatabaseField;
public abstract class DTAbstractModelEntity<T extends DTAbstractEntity> extends DTAbstractEntity {
public final static String ID_FIELD_NAME = "uuid";
@DatabaseField(id = true, canBeNull = false, columnName = ID_FIELD_NAME)
protected String uuid;
@DatabaseField
protected String name;
@DatabaseField
protected String path;
@DatabaseField
protected boolean completeResponse;
/* GETTERS */
public String getUuid() { return uuid; }
public String getName() {
return name;
}
public String getPath() {
return path;
}
public boolean isCompleteResponse() {
return completeResponse;
}
}
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
@DatabaseTable
public class DTProfile extends DTAbstractModelEntity {
@DatabaseField
private int unreadCount;
@DatabaseField
private boolean linkedInAuthorised;
@DatabaseField
private boolean hasSubscriptions;
@DatabaseField(foreign=true, foreignAutoCreate = true, foreignAutoRefresh = true)
private DTLocale localePreference;
@DatabaseField
private String loginType; //email or social login provider ie twitter, google, facebook etc
/* CONSTRUCTOR */
public DTProfile() {
//constructor stub - needed by ORMLite
}
/* GETTERS */
public int getUnreadCount() {
return unreadCount;
}
public boolean isLinkedInAuthorised() {
return linkedInAuthorised;
}
public boolean isHasSubscriptions() {
return hasSubscriptions;
}
public DTLocale getLocalePreference() {
return localePreference;
}
public String getLoginType() { return loginType; }
}
任何人都可以在这里提供了指导,Java代码移植到了C#相当于
非常感谢您的回答。我接受了我之前提出的问题的答案:Xamarin.Android应用程序中使用ORMLite的等效包:) –
@santoshkumarpatro,好的,然后让我检查文档和示例,我在我的答案结尾提供了'SQLite - 网络PCL',这是没有帮助吗? –
我正在尝试该示例。感谢您的链接:) –