首页 \ 问答 \ 选择与Linq to Entities不同(Select Distinct with Linq to Entities)

选择与Linq to Entities不同(Select Distinct with Linq to Entities)

对这个问题的一个扩展问题在这里提出 ,我试图做同样的功能,即

IEnumerable<Customer> filteredList = originalList
  .GroupBy(customer => customer.CustomerId)
  .Select(group => group.First());

在评论中,这暗示着,如果它是Linq实体,并且肯定不适合我,那么我将得到一个空结果集。

对我不起作用! 即使我尝试了'FirstOrDefault',但它不起作用。 - JatSing 11年9月25日在13:55

@JatSing:您必须使用Linq to Entities。 - 乔希Mouch 12年2月14日在14:45

因此,如果上述不适用于实体的Linq,我将如何去分组一个由两列设置的EntityType消息的IEnumerable,然后得到每个组的第一行?


An expansion on the question asked here, I am trying to do the same functionality, namely

IEnumerable<Customer> filteredList = originalList
  .GroupBy(customer => customer.CustomerId)
  .Select(group => group.First());

which in the comments, it was implied that this will not work if it is Linq to Entities and certainly isn't working for me, I get a null result set.

Doesn't work for me ! Even I tried 'FirstOrDefault' it didn't work. – JatSing Sep 25 '11 at 13:55

@JatSing: You must be using Linq to Entities. – Josh Mouch Feb 14 '12 at 14:45

So if the above doesn't work for Linq to Entities, how would I go about grouping an IEnumerable of an EntityType message set by two columns, and then get the first row of each group?


原文:https://stackoverflow.com/questions/40387427
更新时间:2023-04-28 08:04

最满意答案

Webpack接受多个资源根到config。

//webpack.conf.js
module.exports = {
   resolve: {
      root: [__dirname + '/common', __dirname + '/src']
   }
};

现在webpack也将搜索两个目录中的模块。 请注意,该选项仅适用于绝对路径。

有关更多信息,请参阅webpack文档


Webpack accepts multiple resource roots into config.

//webpack.conf.js
module.exports = {
   resolve: {
      root: [__dirname + '/common', __dirname + '/src']
   }
};

Now webpack will search modules in both directories as well. Note that option works only with absolute paths.

See webpack docs for more information.

相关问答

更多
  • Webpack的内置树形抖动仅适用于ES6模块语法。 如果您使用Babel的默认设置,Babel会将ES6模块编译为CommonJS模块,Webpack无法使用。 一般来说,使用Webpack的人会想要传递modules: false使用它们用于ES6的preset-env (可能是preset-env ?),这样做 { presets: [ ['env', { modules: false }], ], } 或者你可以考虑使用像https://github.com/indutny/web ...
  • 问题是如果那是你的webpack配置,你就不能require('react-widgets/lib/less/react-widgets.less') -widgets require('react-widgets/lib/less/react-widgets.less') 。 这是在某个组件内部。 The problem is that if that is your webpack config, you can't require('react-widgets/lib/less/react-widge ...
  • 感谢大家,我已经找到了问题。 在我的.babelrc文件中,我不得不删除transform-runtime插件。 这固定了因为我已经使用了babel-polyfill。 我在某处读到它们可以相互冲突,因此它们不应该一起使用。 我会发布我的.babelrc文件以供参考,如果有其他人碰巧遇到此问题。 或者只是使用一个例子。 { "presets": [ "es2015", "react", "stage-0" ], "plugins": [ "add-module-e ...
  • 如果你使用的是Babel 6.0,那么默认情况下它将不会再次编译你的代码。 ( https://babeljs.io/blog/2015/10/29/6.0.0/ ),它说: 由于Babel专注于成为JavaScript工具的平台,而不是ES2015的编译器,所以我们决定让所有插件选择加入。 这意味着当你安装Babel时,默认情况下它将不再传输你的ES2015代码。 如果要传输代码,则需要安装两个预设: npm install --save-dev babel-preset-es2015 babel-pre ...
  • bundle.js在尚未解析content元素时执行。 只需将script元素移动到标记的位置即可。 bundle.js is executed when the content element isn't yet parsed an created. Just move your script element to the of the markup.
  • Webpack使用explain来加载配置文件。 它需要带有basename webpack.config或webpackfile 第一个文件,并且任何扩展interpret知道。 此外,它优先使用.js文件。 找到配置后,它会注册相应的编译器并需要配置 。 特别是在.babel.js情况下,它试图一个接一个地要求这三个模块 ,直到找到其中一个。 如果成功, babel基本上会挂钩需要文件。 Webpack uses interpret to load configuration file. It take ...
  • 向该语言添加类字段的提议目前处于标准化过程的第2阶段。 Babel'stage'预设的工作方式如下: babel-preset-stage-0仅包含支持Stage 0功能所需的内容。 babel-preset-stage-1包含支持Stage 0 和 1功能所需的内容。 等等,直到babel-preset-stage-4 。 因此,由于您只有babel-preset-stage-3 ,因此无法使用类字段。 要使其正常工作,您应该卸载该软件包,安装babel-preset-stage-2 ,然后相应地更新配置 ...
  • Webpack接受多个资源根到config。 //webpack.conf.js module.exports = { resolve: { root: [__dirname + '/common', __dirname + '/src'] } }; 现在webpack也将搜索两个目录中的模块。 请注意,该选项仅适用于绝对路径。 有关更多信息,请参阅webpack文档 。 Webpack accepts multiple resource roots into config. // ...
  • 您的Babel配置需要更改 ['es2016', 'react'] 至 ['es2015', 'es2016', 'react'] 并安装babel-preset-es2015 npm install --save-dev babel-preset-es2015 Uglify不支持ES6,所以你需要es2015来编译ES6到ES5。 es2016只是编译了ES2016中添加的新功能。 更新: 现在,使用babel-preset-env比使用基于年份的预设更好。 我建议做: presets: [ [ ...
  • 您收到错误是因为您正在调用babel-polyfill的多个实例。 您可以选择两个选项中的任何一个,但不能同时选择两者。 如果使用webpack,请不要将单独的条目指向单独的文件,而是指向目录。 例如:如果您的文件位于app / js中 module.exports = { entry: ['babel-polyfill', './app/js'] }; 如果您决定导入它,请确保在调用其他任何内容之前,只在应用程序的入口点导入/要求它一次。 You are getting the error bec ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)