在 SQL Server CE 中表示时间跨度的最佳方式是什么? [英] What is the best way to represent a timespan in SQL Server CE?

查看:35
本文介绍了在 SQL Server CE 中表示时间跨度的最佳方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

具体来说,我只需要几小时:分钟,但假设我有一个 .NET TimeSpan 对象,我应该如何将它存储在 SQL(CE) 数据库中?

Specifically speaking I only need hours:minutes but say I have a .NET TimeSpan object, how should I store that in a SQL(CE) database?

推荐答案

我建议使用 long 来表示 滴答.这就是 TimeSpan 使用的内部表示.这使您可以轻松地使用 Timespan.FromTicks() 重建您的对象 方法,并使用 Timespan 输出到数据库.Ticks 属性..NET中最小的时间单位是tick,等于100纳秒

I'd recommend using a long to represent the number of ticks. That's what TimeSpan uses as it's internal representation. This lets you easily reconstitute your object with the Timespan.FromTicks() method, and output to the database using the Timespan.Ticks property. The smallest unit of time in .NET is the tick, which is equal to 100 nanoseconds

这篇关于在 SQL Server CE 中表示时间跨度的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆