[已解决] EntityDataSource.CommandText中的嵌套选择 [英] [Solved] Nested Select in EntityDataSource.CommandText

查看:56
本文介绍了[已解决] EntityDataSource.CommandText中的嵌套选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.

当我在entitydatasource.CommandText中使用此选择时:

Hi.

When I use this select in a entitydatasource.CommandText:

CommandText="SELECT it.[LiteratureID], it.[ReleaseDate], it.[Title], it.[Text], it.[ThreadID], it.[Added], (SELECT COUNT(fp.PostID) FROM ForumPosts AS fp WHERE fp.ThreadID = it.[ThreadID] AND fp.Status = 1) AS Posts FROM Literature AS it WHERE it.[Status] = 4 ORDER BY it.[ReleaseDate] DESC SKIP 5 LIMIT 1"



当我绑定数据时,我得到了:



I get this, when I bound the data:

System.Collections.Generic.List`1[System.Data.Common.DbDataRecord] 



应该是数字.

更新:
由OP自己解决.



It should have been a number.

UPDATE:
Resolved by OP himself. Posted as an answer.

推荐答案

找到了解决方案.

将VALUE添加到嵌套的SELECT会返回Int32 insted的列表.

这样绑定,返回值:

评论=''<%#Eval(帖子[0]")%>''
Found a solution.

Adding VALUE to the nested SELECT returned a list of Int32 insted.

Binding like this, returned the value:

Comments=''<%# Eval("Posts[0]") %>''


谢谢.这是一个巨大的帮助!
Thank you. This was a HUGE help!


非常感谢.这确实是一个非常可观的帮助.
我在aspx页面中使用了查询:

< asp:entitydatasource id ="LogsEntityDataSource" runat ="server" connectionstring ="name = CNDBEntities" xmlns:asp =#unknown">
DefaultContainerName ="DBEntities" EnableFlattening ="False" EntitySetName ="Logs"
选择="it.Message,将Count(it.Message)作为Count,将它作为记录器,作为位置,将它作为级别. .Logger和l.Level = it.Level)作为ID"
GroupBy ="it.Message,it.Logger,it.Level"
OrderBy ="it.Count DESC">


绑定时写的如下:
< a href ="/logs/view-all.aspx?id =<%#Eval(" Id [0])%>">查看全部</a>删除</a>

谢谢
Thanks very much. It is really a very appeciatable help.
I used in query like in aspx page :

<asp:entitydatasource id="LogsEntityDataSource" runat="server" connectionstring="name=CNDBEntities" xmlns:asp="#unknown">
DefaultContainerName="DBEntities" EnableFlattening="False" EntitySetName="Logs"
Select="it.Message, Count(it.Message) as Count, it.Logger as Location, it.Level, (Select VALUE l.Id from Logs as l where l.Message = it.Message and l.Logger = it.Logger and l.Level = it.Level) as Id"
GroupBy="it.Message,it.Logger,it.Level"
OrderBy="it.Count DESC" >


While binding written as said :
<a href="/logs/view-all.aspx?id=<%#Eval("Id[0]")%>">View All</a>Delete</a>

Thanks


这篇关于[已解决] EntityDataSource.CommandText中的嵌套选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆