1.数据库建表

CREATE TABLE dbo.Test
(
tId INT IDENTITY NOT NULL
, tName NVARCHAR (20) NOT NULL
, tSalary DECIMAL (8, 2) NULL
, tTimeStamp TIMESTAMP
, PRIMARY KEY (tId)
)

2.创建类

    public partial class Test
{
[SugarColumn(IsPrimaryKey =true,IsIdentity =true)]
public int tId { get; set; }
public string tName { get; set; }
public decimal? tSalary { get; set; }
[SugarColumn(IsOnlyIgnoreInsert = true)]
public byte[] tTimeStamp { get; set; }
}

3.添加数据

SqlSugar.DB.Insertable<Test>(new Test { tName = "Jerry", tSalary = (decimal)7238.04 }).ExecuteCommand();

在Test类的 tTimeStamp 属性上添加[SugarColumn(IsOnlyIgnoreInsert = true)],否则会出错。

4.数据输出

var list = await SqlSugar.DB.Queryable<Test>().ToListAsync();
list.ForEach(x => Console.WriteLine($"{x.tId} {x.tName} {x.tSalary} {BitConverter.ToString(x.tTimeStamp).Replace("-","")}"));

5.条件查询

根据时间戳查询,目标是第二条

var list = await SqlSugar.DB.Queryable<Test>().ToListAsync();
var query = await SqlSugar.DB.Queryable<Test>().Where(x => x.tTimeStamp == list[1].tTimeStamp).ToListAsync();
query.ForEach(x => Console.WriteLine($"{x.tId} {x.tName} {x.tSalary} {BitConverter.ToString(x.tTimeStamp).Replace("-","")}"));

C#:SqlSugar中时间戳(TimeStamp)的使用的更多相关文章

  1. C#更新SQLServer中的TimeStamp字段(时间戳) 防止同时修改一行时覆盖更新

    C#更新SQLServer中的TimeStamp字段(时间戳) 分类: C#2012-10-24 15:10 1878人阅读 评论(0) 收藏 举报 public partial class Form ...

  2. sql server中的TimeStamp时间戳与UniqueIdentifier数据类型

    TimeStamp SQL Server timestamp 数据类型与时间和日期无关.SQL Server timestamp 是二进制数字,它表明数据库中数据修改发生的相对顺序.实现 timest ...

  3. SQLSERVER中的timestamp 和 C#中的byte[] 转换

    项目中由于需求设计,数据库中需要一个timestamp时间戳类型的字段来作为区别数据添加和修改的标识.由于timestamp在SQL SERVER 2005数据库中,不可为空的timestamp类型在 ...

  4. sql server时间戳timestamp

    sql server时间戳timestamp 在SQL Server中联机丛书是这样说的: SQL Server timestamp 数据类型与时间和日期无关.SQL Server timestamp ...

  5. sql中使用timestamp增量抽取数据

    网址:http://www.cnblogs.com/shuaifei/p/4469526.html 最近的项目中需要对上百万级的数据进行增量抽取操作,因此了解了一下TIMESTAMP的应用,特此记录 ...

  6. Android中时间戳的详细解释

    Android中时间戳的详细解释: (1).定义: 时间戳就是根据当前系统时间生成的一组随机数字. (2).作用: 作为对数据唯一性的一种判断依据.避免了重复修改数据所带来的错误! (3).应用: ( ...

  7. ES & Filebeat 使用 Pipeline 处理日志中的 @timestamp

    使用 Pipeline 处理日志中的 @timestamp Filebeat 收集的日志发送到 ElasticSearch 后,会默认添加一个 @timestamp 字段作为时间戳用于检索,而日志中的 ...

  8. mysql的时间戳timestamp精确到小数点后六位

    1.mysql的时间戳timestamp精确到小数点后六位. 公司业务使用到Greenplun数据库,根据查询的时间戳来不断的将每个时间段之间的数据,进行数据交换,但是今天发现,mysql的时间戳没有 ...

  9. js中时间戳转换成时间格式

    js中时间戳转换成时间格式, // 时间戳转换成时间格式 var formatDate = function(date){ date = new Date(date); var y=date.getF ...

  10. 对oracle中date/timestamp的操作

    设置oracle中date的会话格式为 'yyyy-mm-dd hh24:mi:ss' alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss ...

随机推荐

  1. Go 指针逃逸分析

    引用 https://my.oschina.net/renhc/blog/2222104

  2. conda错误 创建新环境conda create -n TF117 python=3.5时报错 An unexpected error has occurred. Conda has prepared the above report.

    创建新环境conda create -n TF117 python=3.5时报错 An unexpected error has occurred. Conda has prepared the ab ...

  3. 霍夫变换原理及实现(Opencv C++)

    已知一幅图像中的n个点,假设我们希望找到这些点中位于直线上的子集.一种可能的解决方法是,首先找到由每对点确定的所有直线,然后寻找靠近特定直线的那些点的所有子集.这种方法涉及寻找n(n-1)/2~n2条 ...

  4. C#.NET HTTP Request 跳过自签名证书校验。

    public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain ...

  5. Vector + ClickHouse 收集日志

    目前业界的日志生态,最常用的是 ELK,其次就是 ClickHouse,本文会演示如何使用 Vector + ClickHouse 来采集 Nginx 日志并做清洗,最终写入 ClickHouse.至 ...

  6. work08

    day09作业: 必做题:========================================第一题: 1.定义一个Animal类,包含如下行为: eat() 打印"要吃饭&qu ...

  7. 报错解决 :Resolved [org.springframework.web.bind.MissingServletRequestParameterException

    报错解决 :Resolved [org.springframework.web.bind.MissingServletRequestParameterException 解决方法:RequestPar ...

  8. es应用服务初始化步骤

    第一步:创建索引+settings+mappingtestes_v1 PUT { "settings": { "index.mapping.total_fields.li ...

  9. 使用python脚本玩转古早TCAD软件(待更新)

    前言 TCAD(Technology Computer Aided Design),虽然原名中没有与半导体器件有关的词汇,但这种软件便是半导体工艺模拟及器件模拟的工具,可以说是EDA软件的一种.TCA ...

  10. [一句话说iOS]dispatch如何造成死锁

    dispatch_sync执行了两件事:把代码块放入指定线程的任务队列中.堵塞当前线程直到代码块执行结束,如果出现了堵塞的线程和代码块所在的线程为同一线程的话,这个时候代码无法在此线程执行继续下去,即 ...