English 中文(简体)
Linq 查询以孙子女财产为基础返回祖父母、父母和孙子女
原标题:Linq query to return grandparent, parent and grandchild based on a grandchild s property
  • 时间:2012-05-22 19:42:50
  •  标签:
  • linq

对不起,我需要查询一个收藏品, 并归还祖父母、父母和孙子女, 以孙子女财产为基础。

例如,在下面的对象下,我想得到引号、比率(父母)和计划(大子女),只要条件与计划ID相符。

public class Quote
{
    public int Id { get; set; }
    public string Type { get; set; }
    public string ParentType { get; set; }
    public decimal ValueMax { get; set; }
    public virtual ICollection<Rate> Rates { get; set; }
}

public class Rate
{
    public int Id { get; set; }
    public decimal ValueMax { get; set; }
    public ICollection<Plan> Plans { get; set; }
}

public class Plan

    public int Id { get; set; }
    public decimal Price { get; set; }
}
最佳回答

你应该能够做这样的事 来得到符合任何标准的计划 以及他们的父母和祖父母的物品

// results is an anonymous type with properties Quote, Rate, Plan
var results = from q in quotes
    from r in q.Rates
    from p in r.Plans
    where p.Id < 500 /* whatever criteria */
    select new 
    {
        Quote = q,
        Rate = r,
        Plan = p
    };
问题回答

暂无回答




相关问题
IEnumerable to array of parameter

Using linq? and XML is there a way to convert this IEnumerable to a string array of the value parameter? List<string> idList = new List<string>(); foreach (XElement idElement in word....

linq query for tag system - search for multiple tags

I have two tables, Tags(tagid, postid, tagname) and posts(postid, name, ...) now i want to make a query that returns me all posts that have a generic amount of tags. like: i want all posts that have ...

Linq operations against a List of Hashtables?

I m working with a set of legacy DAO code that returns an IList, where each Hashtable represents the row of a dynamically executed SQL query. For example, the List might contain the following records/...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

How to filter duplicate list items

i have list of items IList with data that looks list this: GenId TestMode 1 0 1 1 3 0 3 1 4 NULL 2 NULL i want to remove the index ...

C# Grouping/Sorting a Generic List<> using LINQ

Im looking to group and sort a Generic List<>. I have a list of objects representing files and each of these objects has a FileName, FileType and FileDate property. FileType is defined as an ...

热门标签