Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# RavenDb使用Linq基于枚举进行选择,给出了错误的自动生成索引_C#_Linq_Enums_Ravendb - Fatal编程技术网

C# RavenDb使用Linq基于枚举进行选择,给出了错误的自动生成索引

C# RavenDb使用Linq基于枚举进行选择,给出了错误的自动生成索引,c#,linq,enums,ravendb,C#,Linq,Enums,Ravendb,使用RavenDB自动生成的索引抛出错误 主要错误行包括: 第25行,位置4:错误CS1593-委托'System.Func>' 不接受1个参数 第29行,位置5:错误CS0833-匿名类型不能具有 具有相同名称的多个属性 完整的错误消息包含在附件中 代码如下: class Program { static void Main(string[] args) { var documentStore = new DocumentStore {

使用RavenDB自动生成的索引抛出错误

主要错误行包括:

第25行,位置4:错误CS1593-委托'System.Func>' 不接受1个参数

第29行,位置5:错误CS0833-匿名类型不能具有 具有相同名称的多个属性

完整的错误消息包含在附件中

代码如下:

class Program
{
    static void Main(string[] args)
    {
        var documentStore = new DocumentStore
            {
               Url="http://localhost:8080/databases/test"
            };
        documentStore.Initialize();
        var bookName = "Book";
        using (var session = documentStore.OpenSession())
        {
            session.Store(new Book
                {
                    Name = bookName,
                    Posts = new List<BookPost> {new BookPost()
                                {
                                    Title = "A post",
                                    Type = BookPost.BookPostType.BooPost1
                                }
                            }
                });

            session.Store(new Book
                {
                    Name = bookName,
                    Posts = new List<BookPost> {new BookPost()
                                {
                                    Title = "A post",
                                    Type = BookPost.BookPostType.BooPost2
                                }
                            }
                });
            session.SaveChanges();
        }

         using (var session = documentStore.OpenSession())
        {
            var ravenQueryable = session.Query<Book>().Customize(b=>b.WaitForNonStaleResultsAsOfLastWrite()).ToList();
        }

        using (var session = documentStore.OpenSession())
        {
            var bookToGet = new List<string>() {bookName};
            var bookPostToGet = new List<BookPost.BookPostType?> {BookPost.BookPostType.BooPost1};
            var books = session.Query<Book>().Where(b => b.Name.In(bookToGet));
            books = books.Where(b => b.Posts.Any(p => p.Type.In(bookPostToGet)));

            //****** This line throws an error *********//
            var bookPage = books.ToList();

        }


    }
}

public class Book
{
    public String Name { get; set; }

    public List<BookPost> Posts { get; set; }
}

public class BookPost
{
    public string Title { get; set; }

    public BookPostType? Type { get; set; }

    public enum BookPostType
    {
        BooPost1,
        BooPost2,
        BooPost3
    }
}
类程序
{
静态void Main(字符串[]参数)
{
var documentStore=新的documentStore
{
Url=”http://localhost:8080/databases/test"
};
初始化();
var bookName=“Book”;
使用(var session=documentStore.OpenSession())
{
商店(新书)
{
Name=书名,
Posts=新列表{new BookPost()
{
Title=“一篇文章”,
类型=BookPost.BookPostType.BooPost1
}
}
});
商店(新书)
{
Name=书名,
Posts=新列表{new BookPost()
{
Title=“一篇文章”,
类型=BookPost.BookPostType.BooPost2
}
}
});
session.SaveChanges();
}
使用(var session=documentStore.OpenSession())
{
var ravenQueryable=session.Query();
}
使用(var session=documentStore.OpenSession())
{
var bookToGet=new List(){bookName};
var bookPostToGet=新列表{BookPost.BookPostType.BooPost1};
var books=session.Query().Where(b=>b.Name.In(bookToGet));
books=books.Where(b=>b.Posts.Any(p=>p.Type.In(bookPostToGet));
//******这一行抛出一个错误*********//
var bookPage=books.ToList();
}
}
}
公共课堂用书
{
公共字符串名称{get;set;}
公共列表发布{get;set;}
}
公营书亭
{
公共字符串标题{get;set;}
PublicBookPostType?类型{get;set;}
公共枚举BookPostType
{
BooPost1,
BooPost2,
BooPost3
}
}
尝试使用较新的版本:RavenDb build RavenDb.Client.2.5.2666和RavenDb.Client.2.5.2666


完整的解决方案(使用RavenDb软件包:)在我的上提供。

查询中存在一个已知的可空枚举错误,该错误已在RavenDb的最新不稳定版本中修复。

我尝试使用RavenDb.Client.2.5.2698-不稳定,同样的问题。也使枚举不可为空,有相同的错误。你能告诉我你正在使用的版本号吗?升级至2.5.2699版-不稳定。自上一版本以来,测试通过&而不是寿命版本。我是否缺少一些RavenDB设置?还必须更新我的Raven服务器以构建2700才能使其正常工作。