[英]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.