简体   繁体   English

字符串“未定义”未被识别为有效的日期时间。 有一个从索引“0”开始的未知单词

[英]The string 'undefined' was not recognized as a valid DateTime. There is an unknown word starting at index '0'

I have a C#.Net backend and I am querying a cosmos DB for an item that meets a certain criteria.我有一个 C#.Net 后端,我正在查询 cosmos DB 以查找符合特定条件的项目。 A user will select an image if they want to set it as the thumbnail when they do it will trigger this to find the original thumbnail to unset the IsThumbnail attribute.如果用户想要将其设置为缩略图,用户将 select 将触发此操作以查找原始缩略图以取消设置 IsThumbnail 属性。

Here is the LINQ statement (The error occurs here):这里LINQ语句(这里出现错误):

var current = _context.LandImages.AsEnumerable()
                    .Where(li => li.LandId == image.LandId)
                    .FirstOrDefault(li => li.IsThumbnail.HasValue && li.IsThumbnail.Value && li.BlobUri.Contains("/land-images/"));

And here is the data entry in cosmos:是 cosmos 中的数据输入:

{
    "Id": "d0b55439-2ba8-4984-80d5-a1d5d97c95bc",
    "BlobUri": "https://blobStorageurl.windows.net/land-images/e5a7cfca-f0ac-4fcb-9c42-7cc27ffe2caf/d0b55439-2ba8-4984-80d5-a1d5d97c95bc",
    "Caption": null,
    "CreatedDate": "2022-01-11T18:40:15.3924032Z",
    "Discriminator": "LandImage",
    "IsThumbnail": true,
    "LandId": "e5a7cfca-f0ac-4fcb-9c42-7cc27ffe2caf",
    "PartitionKey": "e5a7cfca-f0ac-4fcb-9c42-7cc27ffe2caf",
    "Status": "Uploaded",
    "UpdatedDate": "2022-01-11T18:40:15.5743165Z",
    "id": "LandImage|d0b55439-2ba8-4984-80d5-a1d5d97c95bc",
    "_rid": "X9EjAMtaj1dNHgAAAAAAAA==",
    "_self": "dbs/X9EjAA==/colls/X9EjAMtaj1c=/docs/X9EjAMtaj1dNHgAAAAAAAA==/",
    "_etag": "\"ee05d6cb-0000-0300-0000-61ddcf0f0000\"",
    "_attachments": "attachments/",
    "_ts": 1641926415
}

I don't see anything as undefined so I am having trouble understanding this error message.我没有看到任何未定义的内容,因此我无法理解此错误消息。

you have repeated li.IsThumbnail.HasValue several times.您已经多次重复 li.IsThumbnail.HasValue。 Try this尝试这个

var current = _context.LandImages
                     .Where(li => li.LandId == image.LandId
                      && ( li.IsThumbnail!=null && ((bool)li.IsThumbnail==true))
                      && li.BlobUri.Contains("/land-images/"))
                      .FirstOrDefault();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 FormatException:该字符串未被识别为有效的DateTime。 从索引0开始有一个未知单词 - FormatException: The string was not recognized as a valid DateTime. There is an unknown word starting at index 0 该字符串未被识别为有效的DateTime。 从索引26开始有一个未知词 - The string was not recognized as a valid DateTime. There is an unknown word starting at index 26 该字符串未被识别为有效的 DateTime。 从索引 0 开始有一个未知单词 - The string was not recognized as a valid DateTime. There is an unknown word starting at index 0 无法识别为有效的日期时间。 从索引0开始的未知单词 - Not Recognized as a valid datetime. Unknown word starting at index 0 该字符串未被识别为有效的DateTime。 从索引0开始有一个未知单词。 - The string was not recognized as a valid DateTime. There is an unknown word starting at index 0. label to string 如何解决此错误:System.FormatException:'字符串未被识别为有效的DateTime。 从索引0开始有一个未知单词。 - how to solve this error: System.FormatException: 'The string was not recognized as a valid DateTime. There is an unknown word starting at index 0.' “System.FormatException:‘该字符串未被识别为有效的 DateTime。有一个从索引 0 开始的未知单词。” 在 C# - "System.FormatException: 'The string was not recognized as a valid DateTime. There is an unknown word starting at index 0." in C# “字符串未被识别为有效的日期时间。在读取 CSV 文件时,有一个从索引 0 开始的未知单词” - "String was not recognized as valid Datetime. There is an unknown word starting at index 0" while reading CSV file back 发生异常:-“未将字符串识别为有效的DateTime。 从索引0开始有一个未知词。” - The Exception occured :- “The string was not recognized as a valid DateTime. There is an unknown word starting at index 0.” 该字符串未被识别为有效的DateTime,从索引25开始有一个未知单词 - The string was not recognized as a valid DateTime, There is an unknown word starting at index 25
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM