Click here to Skip to main content
16,020,666 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have been using System.Linq.Dynamic library. Is there a way to use Entities with one to many relationship. To be specific I have 3 classes

class A
{
  public int Id {get;set;}
  ...
  ...
  public Class2 class2 {get;set;}
  public List< Another > Bs{get;set;}
}
class Class2
{
   public int Id{get;set;}
}
class Another
{
   public int Id {get;set;}
}


I can filter when the relationship is one to one
public IQueryable< T > Select< T >(string condition,object value)
{
 var list=FindAll< T >();//return list of T from database
 var result=list.Where(string.Format("{0} = @0",condition),value);
}
result=Select< A >("class2.Id",1);

the above call gives me the list of A objects whose class2's id=1. how can i search if the relationship is one to many.. how do i filter list of A objects based on each object's first item of Bs ie Bs[0]. would it be possible to filter using Linq.Dynamic.
Posted
Updated 16-Nov-10 15:52pm
v3

1 solution

You can possibly implement a property in class A that checks the first item of class2 inside it (or however you want the condition to be), then call this exactly as the example you have given.
After all, underneath the hood LINQ does a for loop. So the logic you can use would be similar.
 
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