![](/img/trans.png)
[英]FormatException: The string was not recognized as a valid DateTime. There is an unknown word starting at index 0
[英]The string 'undefined' was not recognized as a valid DateTime. There is an unknown word starting at index '0'
我有一個 C#.Net 后端,我正在查詢 cosmos DB 以查找符合特定條件的項目。 如果用戶想要將其設置為縮略圖,用戶將 select 將觸發此操作以查找原始縮略圖以取消設置 IsThumbnail 屬性。
這里是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/"));
這是 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
}
我沒有看到任何未定義的內容,因此我無法理解此錯誤消息。
您已經多次重復 li.IsThumbnail.HasValue。 嘗試這個
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.