小编diy*_*da_的帖子

使用Entity Framework Fluent语法或内联语法编写递归CTE

我是SQL和实体框架(ADO.NET实体映射)中的新递归.我正在进行评论管理,我有一个Comments表,表包含列NewsID, CommentID, ParentCommentID, IndentLevel, CreatedTime.

我正在尝试获取特定新闻项目的评论列表,其中所有评论都是根据父母和创建时间下的孩子排列的,如下所示:

CommentID | time | ParentCommentID
Guid1     |  t1  | null
Guid4     |  t4  | Guid1
Guid2     |  t2  | null
Guid3     |  t3  | Guid2
Run Code Online (Sandbox Code Playgroud)

必须优先考虑子父母关系,然后是创建时间.

到目前为止我所倾向的是(来自互联网资源和之前的stackoverflow Q/A)

  • 如图所示,这些递归查询很慢.使用Entity Framework执行此操作甚至更慢.但它可以实现.
  • 因此,可以通过在SQL Server中创建存储过程并使用功能导入来调用它来完成.另一件事是在实体框架中使用Linq.
  • 在SQL Server中,它以此格式使用

SQL:

WITH cte_name ( column_name [,...n] ) 
AS 
( 
CTE_query_definition –- Anchor member is defined. 
UNION ALL 
CTE_query_definition –- Recursive member is defined referencing cte_name. 
) 
-- Statement using the CTE 
SELECT * 
FROM …
Run Code Online (Sandbox Code Playgroud)

c# linq sql-server entity-framework

12
推荐指数
2
解决办法
2万
查看次数

Spring Integration Kafka Consumer Listener无法接收消息

根据这里提供的文档,我正在尝试使用POC将消息传入监听器,如同一文档中所述,下面是我编写配置的方法.

@Configuration
public class KafkaConsumerConfig {

    public static final String TEST_TOPIC_ID = "record-stream";

    @Value("${kafka.topic:" + TEST_TOPIC_ID + "}")
    private String topic;

    @Value("${kafka.address:localhost:9092}")
    private String brokerAddress;


    /*
      @Bean public KafkaMessageDrivenChannelAdapter<String, String> adapter(
      KafkaMessageListenerContainer<String, String> container) {
      KafkaMessageDrivenChannelAdapter<String, String>
      kafkaMessageDrivenChannelAdapter = new
      KafkaMessageDrivenChannelAdapter<>( container, ListenerMode.record);
      kafkaMessageDrivenChannelAdapter.setOutputChannel(received()); return
      kafkaMessageDrivenChannelAdapter; }

      @Bean public QueueChannel received() { return new QueueChannel(); }
     */

    @Bean
    public KafkaListenerContainerFactory<ConcurrentMessageListenerContainer<String, String>> kafkaListenerContainerFactory() {

        ConcurrentKafkaListenerContainerFactory<String, String> factory = new ConcurrentKafkaListenerContainerFactory<>();
        factory.setConsumerFactory(consumerFactory());
        factory.setConcurrency(3);
        factory.getContainerProperties().setPollTimeout(30000);
        return factory;

    }

    /* …
Run Code Online (Sandbox Code Playgroud)

java spring spring-integration apache-kafka

12
推荐指数
1
解决办法
5691
查看次数

Maven无法正确安装

操作无法完成.查看详细信息.

无法完成安装,因为找不到一个或多个必需的项目.

正在安装的软件:m2e - Eclipse的Maven集成(包括Incubating组件)1.6.1.20150625-2338(org.eclipse.m2e.feature.feature.group 1.6.1.20150625-2338)缺少需求:Eclipse的Maven Integration 1.6.0.20150526-2032 (org.eclipse.m2e.core 1.6.0.20150526-2032)需要'bundle org.eclipse.osgi 3.10.0'但找不到它缺少要求:Eclipse的Maven Integration 1.6.1.20150625-2338(org.eclipse.m2e) .core 1.6.1.20150625-2338)需要'bundle org.eclipse.osgi 3.10.0'但无法找到它无法满足依赖性:来自:Maven Integration for Eclipse 1.6.1.20150625-2338(org.eclipse.m2e.core. ui 1.6.1.20150625-2338)To:bundle org.eclipse.m2e.core [1.6.0,1.7.0)无法满足依赖性:来自:m2e - Eclipse的Maven集成(包括Incubating组件)1.6.1.20150625-2338(org.eclipse.m2e.feature.feature.group 1.6.1.20150625-2338)To:org.eclipse.m2e.core.ui [1.6.1.20150625- 2338]

java eclipse maven

10
推荐指数
1
解决办法
1万
查看次数

如何在安装项目中写入app.config并在程序中使用它

  • 我创建了一个Installhelper.cs,它是从Installer中获取的.
  • 使用这段代码(A)覆盖Install()方法.

插入到app.config的这些值在安装后创建的[projectName] .exe.config文件中不可用.我已经手动在app.config中添加了如下所示的部分(B)

数据传递给安装程序类,但数据不会写入app.config字段.它们在安装期间在创建的配置文件中保持相同.

任何帮助是极大的赞赏.我花了将近一天的时间.

代码A:

[RunInstaller(true)]
public partial class Installation : System.Configuration.Install.Installer
{
    public Installation()
    {
        InitializeComponent();
    }

    public override void Install(IDictionary stateSaver)
    {
        //base.Install(stateSaver);

        try
        {
            // In order to get the value from the textBox named 'EDITA1' I needed to add the line:
            // '/PathValue = [EDITA1]' to the CustomActionData property of the CustomAction We added. 

            string userName = Context.Parameters["userName"];
            string password = Context.Parameters["password"];
            string folderPath = Context.Parameters["path"];

            MessageBox.Show(userName);
            MessageBox.Show(password);
            MessageBox.Show(folderPath);

            Configuration config = …
Run Code Online (Sandbox Code Playgroud)

installer app-config visual-studio-setup-proje c#-4.0

7
推荐指数
2
解决办法
9927
查看次数

如何在Antlr4中由解析器给出的运行时收集错误

我已经从Antlr 3升级到Antlr 4.我使用此代码来捕获使用此代码的异常.但这不适用于Antlr 4.

partial class XParser
{
    public override void ReportError(RecognitionException e)
    {
        base.ReportError(e);
        Console.WriteLine("Error in Parser at line " + ":" + e.OffendingToken.Column + e.OffendingToken.Line + e.Message);
    }
}
Run Code Online (Sandbox Code Playgroud)

这是出现的错误

'Parser.ReportError(Antlr4.Runtime.RecognitionException)': no suitable method found to override
Run Code Online (Sandbox Code Playgroud)

在Antlr 4中,累积输入流中发生的错误的预期方式是什么.我无法在网上找到实现这一目标的方法.请给我一些指导.

编辑:

我已经实现了XParser,如下所示

partial class XParser : IAntlrErrorListener<IToken>
{
    public void SyntaxError(IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
    {
        Console.WriteLine("Error in parser at line " + ":" + e.OffendingToken.Column + e.OffendingToken.Line + e.Message);
    }
} …
Run Code Online (Sandbox Code Playgroud)

antlr antlr3 c#-4.0 antlr4

6
推荐指数
1
解决办法
3935
查看次数

VS2012的混合不显示项目模板

我开始使用Blend for VS 2012RC,当我打开Blend然后转到时New Project,我看不到选择项目类型的选项.它完全是空的,如下所示.任何人都可以帮我解决这个问题.

我还尝试在VS2012RC中创建一个WPF项目并在Blend中打开它但我无法获得设计视图.

在此输入图像描述

wpf expression-blend visual-studio-2012

5
推荐指数
1
解决办法
1951
查看次数

Spring Boot-绝对的uri:http://java.sun.com/jsp/jstl/core无法在web.xml或jar文件中解析

我已经找到了解决方案.这是最接近的这个.其中任何一个都没有用.我得到以下异常.我正在使用弹簧靴.我正在运行它作为一个Spring启动应用程序.不在Tomcat里面.

org.apache.jasper.JasperException: /common/taglibs.jsp(9,62) PWC6188: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:92)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:378)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:172)
at org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:431)
at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:240)
at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:502)
at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:582)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1652)
at org.apache.jasper.compiler.Parser.parse(Parser.java:185)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:244)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:161)
at org.apache.jasper.compiler.Parser.processIncludeDirective(Parser.java:394)
at org.apache.jasper.compiler.Parser.parseIncludeDirective(Parser.java:431)
at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:574)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1652)
at org.apache.jasper.compiler.Parser.parse(Parser.java:185)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:244)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:145)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:212)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:625)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1496) …
Run Code Online (Sandbox Code Playgroud)

spring jstl taglib maven spring-boot

5
推荐指数
1
解决办法
4584
查看次数

将平台更改为x64并返回到任何CPU后,.NET项目无法构建

我的.net c#解决方案中有5个项目.我已将每个项目平台更改为Build的平台目标中的x64(这最初是'任何CPU')并且该项目工作正常.

然后我使用解决方案属性中的配置管理器更改了解决方案属性中的平台(右键单击解决方案 - >属性)

然后我改变了然后回到任何CPU.但我无法构建解决方案.有很多错误说无法找到每个项目的dll.

当我在解决方案属性中更改平台并构建内置时,我注意到的一件事从bin/debug更改为bin/x64/debug(我在调试模式下运行)

Ex错误:

Metadata file '[project path]\bin\Debug\Thahavuru.DataAccessLayer.dll' could not be found   
Run Code Online (Sandbox Code Playgroud)

我对成功重建项目的困惑感到困惑.非常感谢帮助.

.net c# configuration visual-studio-2012

4
推荐指数
1
解决办法
3583
查看次数

ELB的AWS证书管理器,指向在EC2上运行的Apache服务器

我正在阅读证书管理器的aws文档.我可以为ELB关联SSL证书.我已经这样做了,我的应用程序仍然驻留在部署在Ubuntu EC2服务器上的Apache服务器上.

在此输入图像描述

在文档中它有以下内容,

注意当前,ACM证书与Elastic Load Balancing负载均衡器或Amazon CloudFront分配相关联.虽然您在Amazon EC2实例上安装了您的网站,但您并未在那里部署ACM证书.而是在您的Elastic Load Balancing负载均衡器或CloudFront分配上部署ACM证书.

据我所知,这意味着我们可以在EC2上部署应用程序,并将其添加到具有ACM证书的负载余额下.

这就是您需要为Web应用程序运行SSL所需的全部内容.

但是当我不使用这种方法时,我使用以下Apache配置来配置SSL.

<VirtualHost *:80>
        DocumentRoot /var/www/html/
        ServerName example.com
        ServerAlias example.com
        ErrorLog ${APACHE_LOG_DIR}/diyoron-error_log
        CustomLog ${APACHE_LOG_DIR}/diyoron-access_log common


        <Directory /var/www/html/>
                RewriteEngine on
                RewriteCond %{HTTPS} off
                RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R]
        </Directory>

</VirtualHost>

<VirtualHost *:443>
        # ServerAdmin webmaster@example.com
        DocumentRoot /var/www/html/

        ServerName example.com
        ServerAlias example.com
        ErrorLog ${APACHE_LOG_DIR}/example-error_log
        CustomLog ${APACHE_LOG_DIR}/example-access_log common
        SSLEngine On

        SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
        SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
        SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem

</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

但在我目前的安排中,我无法在我的Apache配置中配置SSLCertificateKeyFile,SSLCertificateChainFile,SSLCertificateFile.

如果有人能指引我走上一条非常受欢迎的正确道路.

AH00016: Configuration Failed
[Fri Apr 21 23:14:01.184314 2017] [ssl:emerg] [pid 1190] AH02572: Failed to …
Run Code Online (Sandbox Code Playgroud)

apache ssl amazon-ec2 ssl-certificate amazon-web-services

4
推荐指数
1
解决办法
1716
查看次数

访问 ANTLR 4 中的通道并单独解析它们

我已将我的评论添加到 ANTLR 4 中的一个单独频道中。在我的例子中,它是频道 2。

这是我的词法分析器语法。

COMMENT: '/*' .*? '*/' -> channel(2) 
       ;
Run Code Online (Sandbox Code Playgroud)

我想访问这个频道 2 并在这个频道上进行解析以积累评论。所以我将其包含在解析语法中,如下所示:

comment
:COMMENT
;
Run Code Online (Sandbox Code Playgroud)

节目中

        string s = " paring string"
        AntlrInputStream input = new AntlrInputStream(s);
        CSSLexer lexer = new CSSLexer(input); 
       
        CommonTokenStream tokens = new CommonTokenStream(lexer,2);
Run Code Online (Sandbox Code Playgroud)

然后我想对令牌进行解析

var xr = parser.comment().GetRuleContexts<CommentContext>();
Run Code Online (Sandbox Code Playgroud)

因为我想从 CommentContext 对象获取信息,例如Start.Column等。

编辑:

这是改进后的问题

更具体地说,我想获取通道 2 中的所有标记,并使用注释语法解析它们,将所有注释获取到 list( IReadOnly<CommentContext>) 中,以便我可以迭代每个注释并访问诸如起始行、起始列、结束行结束列和标记文本。

CommonTokenStream tokens = new CommonTokenStream(lexer,2);
Run Code Online (Sandbox Code Playgroud)

这并没有给我通道 2 中的标记。我发现的另一件事是,直到这些标记作为参数传递给解析器构造XParser parser = new XParser(tokens);

然后只有我可以通过调用来访问令牌GetTokens()。在令牌中,我可以看到有一些注释被标识为令牌并且位于通道 2 中。尽管CommentTokenStrem指定了上面的通道号。它包含所有令牌。 …

c# antlr antlr4

3
推荐指数
1
解决办法
4182
查看次数