A Class may have one or more Students and One or more Studens may be in a Class. A Class can be given one or more items of HomeWork.
Here is the code:
sisDomainService.metadat.cs:
internal sealed class HomeWorkMetadata
{
// Metadata classes are not meant to be instantiated.
private HomeWorkMetadata()
{
}
public Class Class { get; set; }
public long ClassID { get; set; }
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
[DisplayName("Given Date")]
public DateTime DateHWGiven { get; set; }
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
[DisplayName("Due Date")]
public DateTime DueDate { get; set; }
[DisplayName("Details")]
public string HomeWorkDetails { get; set; }
[ScaffoldColumn(false)]
public long ID { get; set; }
public Subject Subject { get; set; }
public long SubjectID { get; set; }
}
}
sisDomainService.cs:
[RequiresAuthentication]
[RequiresRole("Clerk","Teacher", "Principal", "Student", "Parent")]
public IQueryable<HomeWork> GetHomeWork()
{
if (this.ServiceContext.User.IsInRole("Student"))
{
int intClassID = getClassID();
return this.ObjectContext.HomeWork.Include("Class").Include("Subject").Where(s => s.ClassID == intClassID).OrderByDescending(s => s.ID);
}
if (this.ServiceContext.User.IsInRole("Parent"))
{
List<int> intListofStudentIDs = new List<int>();
intListofStudentIDs = getStudentIDs(getParentID());
List<int> intListofClassIDs = getClassIDs(intListofStudentIDs);
return this.ObjectContext.HomeWork.Include("Class").Include("Subject").Where(s => intListofClassIDs.Any(i => i == s.ClassID)).OrderBy(s => s.ClassID);
//Where(s => intListofStudentIDs.Any(i => i == s.StudentID)
}
return this.ObjectContext.HomeWork.Include("Class").Include("Subject").OrderByDescending(h => h.ID);
}
I'm so sorry. The problem is with the HomeWork table the Name of the Class (Grade 1 or Grade 2, etc.) does not show although the Subject does in the gridview that displays the HomeWork.
It seems you have a WCF RIA Service Domain Service here which does not support M:M out of the box, if you do a search there is a solution on this forum from last year I think.
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
Member
18 Points
187 Posts
A Field is AWOL
May 03, 2013 05:31 AM|mr41971|LINK
The problem is with the HomeWork table the Class does not show although the Subject does.
I have three tables:
1. Class: ID, Name, TeacherID
2. ClassStudent: ID, ClassID, StudentID
3. HomeWork: ID, ClassID, SubjectID, DateGiven, DueDate, Details
A Class may have one or more Students and One or more Studens may be in a Class. A Class can be given one or more items of HomeWork.
Here is the code:
sisDomainService.metadat.cs:
sisDomainService.cs:
Please help thank you.
Contributor
2320 Points
634 Posts
Re: A Field is AWOL
May 05, 2013 05:35 PM|Illeris|LINK
Could you please clarify your question or problem?
http://illerisblog.wordpress.com/
Member
18 Points
187 Posts
Re: A Field is AWOL
May 05, 2013 06:48 PM|mr41971|LINK
I'm so sorry. The problem is with the HomeWork table the Name of the Class (Grade 1 or Grade 2, etc.) does not show although the Subject does in the gridview that displays the HomeWork.
I hope this clears things up for you matee.
All-Star
17916 Points
5681 Posts
MVP
Re: A Field is AWOL
May 10, 2013 12:33 PM|sjnaughton|LINK
It seems you have a WCF RIA Service Domain Service here which does not support M:M out of the box, if you do a search there is a solution on this forum from last year I think.
Always seeking an elegant solution.
Member
18 Points
187 Posts
Re: A Field is AWOL
May 10, 2013 03:45 PM|mr41971|LINK
How are you Steve I hope all is well with you and your family. God bless you and those you love.
All-Star
17916 Points
5681 Posts
MVP
Re: A Field is AWOL
May 11, 2013 09:29 AM|sjnaughton|LINK
I'm getting better still not fully recovered after my operation :)
Always seeking an elegant solution.
None
0 Points
5 Posts
Re: A Field is AWOL
May 14, 2013 08:59 AM|teyc|LINK
Get well soon. Thanks for being so helpful around here.
All-Star
17916 Points
5681 Posts
MVP
Re: A Field is AWOL
Jun 12, 2013 08:53 AM|sjnaughton|LINK
did you find that domain service solution I said was on the forum?
Always seeking an elegant solution.
Member
18 Points
187 Posts
Re: A Field is AWOL
Jun 12, 2013 09:25 AM|mr41971|LINK
Yes this problem was solved.
All-Star
17916 Points
5681 Posts
MVP
Re: A Field is AWOL
Jun 12, 2013 10:06 AM|sjnaughton|LINK
can you post a link here to the solution and mark as answer :)
Always seeking an elegant solution.
Member
18 Points
187 Posts
Re: A Field is AWOL
Jun 12, 2013 10:11 AM|mr41971|LINK
If I remember correctly I think I was missing an Include.
Member
18 Points
187 Posts
Re: A Field is AWOL
Jun 12, 2013 10:11 AM|mr41971|LINK
Also I sent you an email.