我正在使用实体框架在ASP.NET MVC中开发web应用程序。它是一种用于聊天的票务日志工具。因此,如果聊天进入代理将复制电子邮件,聊天日期和开始时间,点击提交。这将简单地在工具中创建一个用于聊天的条目,其中包含以下字段:
Email, ChatStartDateTime, ChatCreatedDateTime所以ChatStartDateTime和ChatCreatedDateTime是不同的。
现在代理共享对聊天的支持,并且可能是他在10分钟后结束了聊天。现在,他回到web应用程序,并添加了他的评论为采取的行动,在网上聊天应用,并点击一个按钮CHATCOMPLETE。
单击此按钮将更新其他字段属性,如Description字段和ChatEndDateTime。
那么,现在我如何才能知道这些字段之间的持续时间
聊天模型类:
public class Chat
{
[Key]
public int ChatId { get; set; }
[Required]
public string CustName { get; set; }
public string Query { get; set; }
public string Resolution { get; set; }
[Required]
public DateTime ChatStartDateTime { get; set; }
public DateTime? ChatCreateDateTime { get; set; }
public DateTime? ChatEndDateTime { get; set; }
public int Id { get; set; }
public string Username { get; set; }
public string FirstName { get; set; }
public string Email { get; set; }
[ForeignKey("Id")]
public virtual User User { get; set; }
}ChatLog控制器动作
public ActionResult MyChats()
{
using (Db db = new Db())
{
Chat dto = new Chat();
var uName = User.Identity.Name;
ViewBag.myTodayTicket = db.Chats.Where(x => System.Data.Entity.DbFunctions.TruncateTime(x.ChatCreateDateTime) == DateTime.Today && x.Username == uName).Count();
return View(db.Chats.Where(x => x.Username == uName).ToArray().ToList());
}
}帮助是非常感谢的。
发布于 2020-10-19 18:08:55
下面是如何解决它的方法@( item.ChatEndDateTime-item.ChatCreateDateTime)). ({0:hh\:mm\:ss}“{0:hh\:ss}”))现在检查我如何统计所有的聊天日志,并得到平均记录。
https://stackoverflow.com/questions/64429337
复制相似问题