简体   繁体   English

如何在SQLServer中设计周期时间(营业时间)?

[英]How to design period time(business hours) in the SQLServer?

I have such a scene like this: In my system, there are some opening time for a food store. 我有这样一个场景:在我的系统中,有一些食品店的开放时间。 The business scene like this: 像这样的商业场景:

For my food store which named 'Pet food', it will be open from Tuesday to Friday, from 11 am to 2 pm. 对于我的名为“宠物食品”的食品店,它将于周二至周五上午11点至下午2点开放。

I want to know that how to better store these business hours. 我想知道如何更好地存储这些营业时间。

I use the Sql Server database, and the Entity Framework core. 我使用Sql Server数据库和Entity Framework核心。

I found that some guys suggest using the xml data type for the business hours in Sql Server. 我发现有些人建议在Sql Server中使用xml数据类型进行营业时间。 If I do this, how do I use entity framework core to query the business hours and how display it on the html. 如果我这样做, 我如何使用实体框架核心来查询营业时间以及如何在html上显示它。

I want to show the open business hours in the web. 我想在网上展示营业时间。 When someone get into this web store, if he add a access reservation that he will visit this store. 当有人进入这个网上商店时,如果他添加访问预订,他将访问该商店。 Then the system will be check his appointment time is valid 然后系统将检查他的预约时间是否有效

You may wish to use Entity Framework's "Value Objects" feature. 您可能希望使用Entity Framework的“值对象”功能。

This allows you to have the SQL representation eg a number for the day of the week 1 - 7, and a SQL TIME as the opening time and SQL TIME as the closing time composed back into a single object which says the opening hours. 这允许您拥有SQL表示形式,例如一周中1-7天的数字,以及作为开放时间的SQL TIME和作为关闭时间的SQL TIME组成一个表示开放时间的单个对象。

https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/microservice-ddd-cqrs-patterns/implement-value-objects#important-characteristics-of-value-objects https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/microservice-ddd-cqrs-patterns/implement-value-objects#important-characteristics-of-value-objects

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM