当我用SQLite构建MVC5模型时。时间跨度很棘手所以我存储了刻度线。但后来我在显示名称上遇到了麻烦。
[PetaPoco.TableName("UserStatus")]
[PetaPoco.PrimaryKey("iUserId", AutoIncrement = true)]
public class User
{
[Column]
[DisplayName("User ID")]
public int iUserId { get; set; }
[Column]
[DisplayName("User Name")]
public string sUserName { get; set; }
//[DisplayName("Average Time")] this line won't work
public TimeSpan tsAvgTime;
[Column]
public long longAvgTimeTick
{
get { return tsAvgTime.Ticks; }
set { tsAvgTalkTime = new TimeSpan(value); }
}
}
那么我应该怎样做才能添加显示名称,而不是更改视图上的显示。
答案 0 :(得分:2)
我怀疑是因为你没有创建 Property 而是 Field 。
它应该是使其有效的属性。
将其更改为:
C:\Users\Rajadurai\Desktop\hello>cordova build
Android Studio project detected
ANDROID_HOME=C:\Users\Rajadurai\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_102
studio
:wrapper
BUILD SUCCESSFUL
Total time: 27.744 secs
Subproject Path: CordovaLib
Subproject Path: app
Starting a Gradle Daemon, 2 incompatible and 1 stopped Daemons could not be reused, use --status for details
Download https://jcenter.bintray.com/it/unimi/dsi/fastutil/7.2.0/fastutil-7.2.0.jar
现在这应该有效。
修改强>
刚刚注意到您正在使用支持字段。您需要在此处[DisplayName("Average Time")]
public TimeSpan tsAvgTime {get;set;}
属性上应用该属性,并将该字段设为私有,即longAvgTimeTick
所以它应该是:
private TimeSpan tsAvgTime