2017-03-23 49 views
0

我有一個時間戳列在我的SQL服務器表中的一個維護行版本, ,但我不知道如何顯示其劍橋網格上的值, 這是必需的因爲我的實體不會更新該列中具有空值的記錄,通過在網格上顯示時間戳值,我將在更新記錄時將其取回。 這是我的劍道電網架構如何在劍道網格Java腳本中顯示Sql Server時間戳列

schema: { 
      errors: function(response) { 
       if (response.Voucher && response.Voucher !== "True") { 
        return response.Voucher; 
       } 
       return false; 
      }, 
      data: "data", 
      total: "total", 
      model: { 
       id: "ID", 
       fields: { 
        ID: { editable: false, nullable: true }, 
        FK_Category_ID: { defaultValue: -1, validation: { required: { message: "" } } }, 
        CompanynameAr: { type: "string", validation: { required: { message: " " } } }, 
        CompanynameEn: { type: "string" }, 
        FK_Country_ID: { defaultValue: -1, validation: { required: { message: "" } } }, 

        Address: { type: "string", validation: { required: { message: "" } } }, 
        PoBox: { type: "string" }, 
        Contractno: { type: "number", validation: { required: { message: "" },min:0 } }, 
        Refrence: { type: "number",validation:{min:0}}, 
        RemarksMarketing: { type: "string" }, 
        Active: { type: "string" }, 
        Latitude: { type: "string" }, 
        Longitude: { type: "string" }, 
        RowVersion: { 
         type: "date", parse: function (value) { 
          return new Date(value * 1000); 
         } 
        } 

        //Address 
       } 
      } 
     } 

這裏RowVersion是我的專欄持有時間戳值,分析功能,只需點擊,並嘗試解決特定的問題,但不會SUCESSFUL。需要幫助

回答

0

正如您在MSDN上看到的,sql server Timestamp值是.net字節數組,因此您無法將其轉換爲Date值。

您可以簡單地對接收到的值不做任何轉換,只是隱藏它。

+0

什麼是數據類型?因爲我必須在控制器的操作上收到這個值。 –

1

在服務器端,添加或更新記錄時,不應在查詢中包含時間戳(RowVersion)列(即使值爲NULL)。 SQL Server將自動爲任何記錄的每次更改生成RowVersion列的值。因此,如果您使用普通SQL,請從SQL中移除RowVersion;或者,如果您使用Entity Framework Code-First,則可以使用[DatabaseGenerated(DatabaseGeneratedOption.Computed)]屬性通知Entity Framework它不應更新相關列。

無論如何,如果你想顯示時間戳(rowversion)的價值,您的用戶,這是通常映射到byte[]類型的8個字節自動遞增的整數,你可以使用BitConverter.ToInt64()將其轉換爲一個long並顯示給用戶。但是您不需要在控制器中接收添加/更新請求,因爲您不應將其包含在查詢中。