C#:您的过滤器和订购LINQ查询如何
通过Entity Framework(EF 6)将Winforms应用程序连接到电影SQL Server数据库。
我有以下SQL,我正在尝试将其转换为linq查询
SELECT m.title,f.path,f.size FROM movie m, MovieLinkFile mlf, "file" f
WHERE m.id = mlf.movieId AND mlf.fileId = f.id
AND f.path like 'M%'
ORDER BY f.size
返回
12345,m \ pathto \最佳电影2022 \ best move.mkv,1.54 GB,720p
varchar(max)类型
尺寸是数据库中的
Movies (id, Title, Year, IMDB,etc)
MoviesLinkFiles (id, MovieId, FileId)
Files (id, path, size, etc)
:这将允许我选择一个以上的电影,这些电影从开车M?
var Movies = context.movies.AsQueryable()
.Where(m => m.files.Count(file => file.path.StartsWith("M:\\")) > 1)
.OrderBy(movie => movie.title);
我如何在C#中写下LINQ语句
file.path.StartsWith("M:\\")
,
OrderBy (file.size)?
在此示例中,我不需要计算文件
错误错误
var Movies = context.movies.AsQueryable()
.Where(m => m.files.Any(file => file.path.StartsWith("M:\\")))
.OrderBy(movie => movie.files.Any(f => f.size) );
错误CS1662无法将lambda表达式转换为预期的委托类型,因为块中的某些返回类型不是隐式转换到委托返回类型
have a WinForms application connected to a Movies SQL Server database via Entity Framework (EF 6).
I have the following SQL which I'm attempting to convert into a LINQ query
SELECT m.title,f.path,f.size FROM movie m, MovieLinkFile mlf, "file" f
WHERE m.id = mlf.movieId AND mlf.fileId = f.id
AND f.path like 'M%'
ORDER BY f.size
returns
12345, M\PathTo\Best movie 2022\Best move.mkv,1.54 GB, 720p
size is type Varchar(max)
In the database there are 3 tables:
Movies (id, Title, Year, IMDB,etc)
MoviesLinkFiles (id, MovieId, FileId)
Files (id, path, size, etc)
This will allow me to select the movies that have more than one file starting with drive M?
var Movies = context.movies.AsQueryable()
.Where(m => m.files.Count(file => file.path.StartsWith("M:\\")) > 1)
.OrderBy(movie => movie.title);
How do I write the LINQ statement in C# so
file.path.StartsWith("M:\\")
AND
OrderBy (file.size)?
In this example I don't need to count files
My attempt errors
var Movies = context.movies.AsQueryable()
.Where(m => m.files.Any(file => file.path.StartsWith("M:\\")))
.OrderBy(movie => movie.files.Any(f => f.size) );
Error CS1662 Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您正在寻找这样的东西:
I think that you looking for something like this: