Format exception - RavenDB LINQ query

跟風遠走 提交于 2019-12-25 05:14:52

问题


I am getting a input string format error in the following bit of code... While debugging code, this runs as a single line of code and so I am not able to dig deep into what might be causing the format exception.. can any one please point to me what I am doing wrong.. thank you.

Exception:

FormatException was unhandled by user code:
"Input string was not in correct format"

Code:

store.DatabaseCommands.UpdateByIndex("Movies/NewIndexName",
             new IndexQuery
             {
                 Query =
         string.Format("Status:Released AND IsDeleted:false AND ReleaseDate:{* TO {0}}",
         DateTools.DateToString(new DateTime(2012, 4, 3),
                                DateTools.Resolution.MILLISECOND))
             },
             new[]
            {
              new PatchRequest
                  {
                      Type = PatchCommandType.Modify,
                      Name = "Status",
                      Value = "TestingReleased"
                   }
            }, allowStale: false);

回答1:


The problem is inside string.Format, You need the value to be:

    {{* TO {0}}}

In other words, you need to escape the { }



来源:https://stackoverflow.com/questions/10273253/format-exception-ravendb-linq-query

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!