我需要使用简单查询构建器生成sql查询我已将所需的dll添加到我的项目中这是我的代码..
<keqwc:EntitiesPanel ID="EntitiesPanel1" runat="server" BorderStyle="None" ToolTip="Entities and attributes"
UseAppearanceStyle="False" ToolBarOnTop="False" UseDefaultStyle="False" Height="600px" Width="100%">
</keqwc:EntitiesPanel>
<keqwc:QueryColumnsPanel ID="QueryColumnsPanel1" runat="server" BorderStyle="none"
ToolTip="Result Columns" UseDefaultStyle="False"
UseAppearanceStyle="False"
Appearance-RowButtonTooltip="Click here to see all available operations" height="170px" Width="100%">
</keqwc:QueryColumnsPanel>
<keqwc:SortColumnsPanel ID="SortColumnsPanel1" runat="server" ToolTip="Columns Sorting" BorderStyle="none" UseDefaultStyle="False"
UseAppearanceStyle="False" Width="100%" height="170px">
</keqwc:SortColumnsPanel>
<keqwc:QueryPanel ID="QueryPanel1" runat="server"
BorderStyle="none" ScrollBars="Auto"
Appearance-ScriptMenuStyle-ItemMinWidth="160"
UseListCache="True"
UseDefaultStyle="False" UseAppearanceStyle="False" Height="200px" Width="100%">
</keqwc:QueryPanel>
<asp:TextBox ID="SqlTextBox" runat="server" TextMode="MultiLine" Height="215px" width="100%"></asp:TextBox>
并且在后面的代码中我添加了使用..
加载实体模型private DbQuery query = null;
protected void Page_Load(Object sender, EventArgs e)
{
query = (DbQuery)Session["QUERY"];
if (query == null)
{
string modelPath = "C:\\Users\\Public\\Documents\\KorzhEasyQuery\\samples\\WebDemoAjaxCS\\App_Data\\NWindMDB.xml";
Korzh.EasyQuery.DataModel model = new Korzh.EasyQuery.Db.DbModel();
model.LoadFromFile(modelPath);
query = new Korzh.EasyQuery.Db.DbQuery();
query.Model = model;
query.Formats.SetDefaultFormats(FormatType.MsSqlServer);
Session["QUERY"] = query;
QueryPanel1.Query = query;
QueryColumnsPanel1.Query = QueryPanel1.Query;
EntitiesPanel1.Query = QueryPanel1.Query;
SortColumnsPanel1.Query = QueryPanel1.Query;
}
}
我需要根据指定的条件生成sql查询,排序顺序和列如何继续这个...?
单击添加列并选择所选列未在给定查询面板中显示的列。
答案 0 :(得分:0)
将最后4行移到“if”语句之外:
if (query == null)
{
. . . . .
}
QueryPanel1.Query = query;
QueryColumnsPanel1.Query = QueryPanel1.Query;
EntitiesPanel1.Query = QueryPanel1.Query;
SortColumnsPanel1.Query = QueryPanel1.Query;
每个Session会初始化一次DbQuery和DbModel对象,但每次回发都会重新创建可视控件(QueryPanel,QueryColumnsPanel等) - 所以你应该在表单加载时分配你的DbQuery对象。