Warning: Constant USER_COOKIE already defined in /var/www/admin/www/markimarta.ru/wp-config.php on line 85

Warning: Constant PASS_COOKIE already defined in /var/www/admin/www/markimarta.ru/wp-config.php on line 86

Warning: Constant AUTH_COOKIE already defined in /var/www/admin/www/markimarta.ru/wp-config.php on line 87

Warning: Constant SECURE_AUTH_COOKIE already defined in /var/www/admin/www/markimarta.ru/wp-config.php on line 88

Warning: Constant LOGGED_IN_COOKIE already defined in /var/www/admin/www/markimarta.ru/wp-config.php on line 89

Warning: Constant TEST_COOKIE already defined in /var/www/admin/www/markimarta.ru/wp-config.php on line 90
Исправление ошибки Error LINQ to Entities does not recognize the method ‘System.Guid Parse(System.String)’ « Марк и Марта.Ру. Записки отца-программиста




Исправление ошибки Error LINQ to Entities does not recognize the method 'System.Guid Parse(System.String)'


Warning: Undefined variable $thumbnail in /var/www/admin/www/markimarta.ru/wp-content/themes/markimarta2023/single.php on line 44

Warning: Attempt to read property "ID" on null in /var/www/admin/www/markimarta.ru/wp-content/themes/markimarta2023/single.php on line 44

Warning: Undefined variable $thumbnail in /var/www/admin/www/markimarta.ru/wp-content/themes/markimarta2023/single.php on line 45

Warning: Attempt to read property "post_title" on null in /var/www/admin/www/markimarta.ru/wp-content/themes/markimarta2023/single.php on line 45

При компиляции MVC решения с использованием EntitiFramework столкнулся с ошибкой "LINQ to Entities does not recognize the method 'System.Guid Parse(System.String)' method, and this method cannot be translated into a store expression."

Line 25: Take(_perPage).ToList());
Line 26: }
Line 27: return View(db.tbl_Department.Where(z => z.Status != 4).Where(x=>x.Parent == Guid.Parse(_rootDepartment)).
Line 28: Take(_perPage).ToList());
Line 29:

Причина ошибки оказалась в том, что EntityFramework пытается сделать из Guid.Parse SQL запрос, а такой SQL запрос не может быть сформирован.

 Exception Details: System.NotSupportedException: LINQ to Entities does not recognize the method 'System.Guid Parse(System.String)' method, and this method cannot be translated into a store expression.

Для исправления нужно просто вынести Guid.Parse(string) за границы лямбда-выражения.

var guidDep = Guid.Parse(id);
            
            return View(db.tbl_Department.Where(z => z.EntityStatus != 4).Where(x => x.Parent == guidDep).

 


Комментариев нет »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment





Срок проверки reCAPTCHA истек. Перезагрузите страницу.



MarkiMarta.ru. Записки отца-программиста" с 2009 г.
Категория информационной продукции 18+
Яндекс.Метрика