Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
HI

I have 2 Classes with following properties

VB
ClsEmployee
(
   EmpID: Integer
   Gender:  integer( 0 means male, 1 means female)
   Name: String
   Children: listOf ClsChildren
}

ClsChildren
(
   ChildName String
   Gender integer( 0 means boy, 1 means girl)
   Age integer
)


I have a list of Employees using which

I need to get the Max,Min, and average age of female children for female employee.

Thanks
Ninad

[edit]Code block added[/edit]
Posted
Updated 19-Feb-14 18:20pm
v4
Comments
Nelek 17-Feb-14 6:59am    
This is not how CP usually works. Most important goal here is to learn and help learning.
You are supposed to try it on your own, and come here when you got stuck with something, with a concrete question about your code, design, etc.
Please have a look to What have you tried?[^] to see a good explanation about what I mean.
Don't forget people here don't get payed. And besides, if we give you a ready-to-go solution, it is not going to help you because you are not going to learn anything from it.
Nelek 17-Feb-14 7:00am    
By the way... didn't you forgot the ":" in the second class? and the format of "age"?
Member 9657520 20-Feb-14 0:21am    
Hi nelek,

we had tried for multiple options which did not work. so the intention was not to get a ready to go solution.

you are absolutely right that I should have provided the options that were tried. this would have also helped us point to the problem.

Finally we were able to solve it.

I have added to the solution

Thanks for the tip. will keep this in mind.

SQL
(From Employee As ClsEmployee In lstEmployee Where Employee.Gender = 1 Select _
     (From Children As clsChildren In Employee.Children Where Children.Gender = 1 _
            Select Children.Age).SingleOrDefault)


similarly .Average and .Min commands will give the other two results
 
Share this answer
 
I am not familiar with vb.net syntax, but i think,you will need to take a look at the SelectMany statement in LINQ
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900