English 中文(简体)
采用指数在清单中列明的不动产
原标题:Get nested properties out in a list - using Index

我正试图获得利用RavenDB的MVC传闻的所有名字清单。 因此,我期待着在一份文件中从被封锁的物体中点名的人名单上登记......

Sample RavenDB 文件:

{
    "City": "NY",

    "Theaters": [
        {
            "TheaterName": "TheaterA",
            "TheaterId": "Theater/1693",
            "Description": ""               
        },
        {
            "TheaterName": "TheaterB",
            "TheaterId": "Theater/16393",
            "Description": ""               
        }
    ]
}

指数(GetCity Theaters Index):

docs.CityTheaters
    .Select(doc => new {Theaters = doc.Theaters, City= doc.City})

法典:

 var query =  

 session.Advanced.LuceneQuery<CityTheaters>("CityTheaters/GetCityTheatersIndex");

我如何操纵上述变数的“频率”,以获得一份简剧清单,现在,上述代码使我获得一份全书的“频率”。 我需要能够把nes物体中的“星号”划入一个清单。 感谢任何帮助。

我尝试了这样的东西。

问询.ElementAt(1),但那是一例。

最佳回答

你们可以使用一个有实地储存的地图索引,以便:

public class CityTheaters : AbstractIndexCreationTask<City>
{
    public class Result
    {
        public string Name { get; set; }
    }

    public CityTheaters()
    {
        Map = cities => from city in cities
                        from theater in city.Theaters
                        select new
                        {
                            theater.Name
                        };

        Store(x => x.Name, FieldStorage.Yes);
    }
}

后来,你可以问:

var results = session.Query<City, CityTheaters>()
    .AsProjection<CityTheaters.Result>()
    .ToList();
问题回答

暂无回答




相关问题
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 ...

热门标签