我想將使用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',這是沒有幫助嗎? –
我正在嘗試該示例。感謝您的鏈接:) –