组委会几周和几天 [英] Organising Weeks and Days
问题描述
我提出要求并组织周,这是在组织成转年每天读一个MVC应用程序。我有一个星期的实体,并且一天实体,其分别为周和天的表。有什么方法可以让我的日子链接到 WeekNo
,但没有 WeekNo
或 DayNo
作为主键?
例如,有会是5个工作日:
WeekNo = 1,DayNo = 1
WeekNo = 1,DayNo = 2
WeekNo = 1,DayNo = 3
WeekNo = 1,DayNo = 4
WeekNo = 1,DayNo = 5
然后,当第2周到来:
WeekNo = 1,DayNo = 1
不过,再有就是1天。重复
我有一年的周类似的问题,当明年的到来,它的回1周,有一个在周重复。但是,如果我能得到过去,这,也许我就能够明白这一点了。
我怎么会去引用这些彼此?
天
模型:
使用系统;
使用System.Collections.Generic;
使用System.Linq的;
使用的System.Web;命名空间Utility.Models
{
公共类日
{
公众诠释大卫·{搞定;组; }
公众诠释WeekNo {搞定;组; }
公众诠释DayNo {搞定;组; }
公共字符串DAYOFWEEK {搞定;组; }
公众持股量Reading1 {搞定;组; }
公众持股量Reading2 {搞定;组; }
//等等 公共虚拟周周{搞定;组; } }
}
星期
模型:
使用系统;
使用System.Collections.Generic;
使用System.Linq的;
使用的System.Web;
使用System.ComponentModel.DataAnnotations.Schema;命名空间Utility.Models
{
公共类周
{
公众诠释WeekID {搞定;组; }
公众诠释WeekNo {搞定;组; }
公众诠释YearID {搞定;组; } 公共虚拟年份{搞定;组; }
公共虚拟的ICollection<白天>天{搞定;组; } }
}
如何多对多的关系?
公共类日
{
公众诠释大卫·{搞定;组; }
公众诠释DayNo {搞定;组; }
公共虚拟的ICollection<平日及GT;平日{搞定;组; }
}
公共类周
{
公众诠释WeekID {搞定;组; }
公众诠释WeekNo {搞定;组; }
公共虚拟的ICollection<平日及GT;平日{搞定;组; }
}
公共类平日
{
公众诠释WeekDayID {搞定;组; }
公众诠释大卫·{搞定;组; }
公共虚拟天天{搞定;组; }
公众诠释WeekID {搞定;组; }
公共虚拟周周{搞定;组; }
}
I am making an MVC application that requires daily readings which are organised into weeks, which are in turn organised into years. I have a week entity, and a day entity, which are tables of weeks and days respectively. Is there any way I can link the days to a WeekNo
but not have WeekNo
or DayNo
as the primary keys?
For example, there'd be 5 working days in week 1:
WeekNo = 1, DayNo = 1
WeekNo = 1, DayNo = 2
WeekNo = 1, DayNo = 3
WeekNo = 1, DayNo = 4
WeekNo = 1, DayNo = 5
Then when Week 2 comes along:
WeekNo = 1, DayNo = 1
But then there is a duplicate of Day 1.
I am having a similar problem with the weeks in a year, that when the next year comes along and it's back to Week 1, there's a duplicate in weeks. But if I can get past this, maybe I would be able figure that out too.
How would I go about referencing these to each other?
Day
model:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Utility.Models
{
public class Day
{
public int DayID { get; set; }
public int WeekNo { get; set; }
public int DayNo { get; set; }
public string DayofWeek { get; set; }
public float Reading1 { get; set; }
public float Reading2 { get; set; }
//etc
public virtual Week Week { get; set; }
}
}
Week
model:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations.Schema;
namespace Utility.Models
{
public class Week
{
public int WeekID { get; set; }
public int WeekNo { get; set; }
public int YearID { get; set; }
public virtual Year Year { get; set; }
public virtual ICollection<Day> Days { get; set; }
}
}
How about many to many relationship?
public class Day
{
public int DayID { get; set; }
public int DayNo { get; set; }
public virtual ICollection<WeekDay> WeekDays { get; set; }
}
public class Week
{
public int WeekID { get; set; }
public int WeekNo { get; set; }
public virtual ICollection<WeekDay> WeekDays { get; set; }
}
public class WeekDay
{
public int WeekDayID { get; set; }
public int DayID { get; set; }
public virtual Day Day { get; set; }
public int WeekID { get; set; }
public virtual Week Week { get; set; }
}
这篇关于组委会几周和几天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!