如何在QueryOver语句中调用标量函数

时间:2016-05-13 11:35:52

标签: c# .net nhibernate hql queryover

我在<form class="form-horizontal" role="form" method="post" action="navigation.tphp"> <div class="form-group"> <label for="name" class="col-sm-2 control-label">Name</label> <div class="col-sm-10"> <input type="text" class="form-control" id="name" name="name" placeholder="First & Last Name" value="<br /> <b>Notice</b>: Undefined index: name in <b>C:\xampp\htdocs\navigation.php</b> on line <b>113</b><br /> "> <br /> <b>Notice</b>: Undefined variable: errName in <b>C:\xampp\htdocs\navigation.php</b> on line <b>114</b><br /> <p class='text-danger'></p> </div> </div> <div class="form-group"> <label for="email" class="col-sm-2 control label">Email</label> <div class="col-sm-10"> <input type="email" class="form-control" id="email" name="email" placeholder="example@domain.com" value="<br /> <b>Notice</b>: Undefined index: email in <b>C:\xampp\htdocs\navigation.php</b> on line <b>120</b><br /> "> <br /> <b>Notice</b>: Undefined variable: errEmail in <b>C:\xampp\htdocs\navigation.php</b> on line <b>121</b><br /> <p class='text-danger'></p> </div> </div> <div class="form-group"> <label for="message" class="col-sm-2 control-label">Message</label> <div class="col-sm-10"> <textarea class="form-control" rows="4" name="message"><br /> <b>Notice</b>: Undefined index: message in <b>C:\xampp\htdocs\navigation.php</b> on line <b>127</b><br /> </textarea> <br /> <b>Notice</b>: Undefined variable: errMessage in <b>C:\xampp\htdocs\navigation.php</b> on line <b>128</b><br /> <p class='text-danger'></p> </div> </div> <div class="form-group"> <label for="human" class="col-sm-2 control-label">2 + 3 = ?</label> <div class="col-sm-10"> <input type="text" class="form-control" id="human" name="human" placeholder="Your Answer" value="<br /> <b>Notice</b>: Undefined index: human in <b>C:\xampp\htdocs\navigation.php</b> on line <b>134</b><br /> "> <br /> <b>Notice</b>: Undefined variable: errHuman in <b>C:\xampp\htdocs\navigation.php</b> on line <b>135</b><br /> <p class='text-danger'></p> </div> </div> <div class="form-group"> <div class="col-sm-10 col-sm-offset-2"> <!-- Will be used to display an alert to the user --> <br /> <b>Notice</b>: Undefined variable: result in <b>C:\xampp\htdocs\navigation.php</b> on line <b>141</b><br /> </div> </div> </form> 中有一个标量函数我想在HQL中的QueryOver中使用它。

请将给定SQL转换为HQL。

<form class="form-horizontal" role="form" method="post" action="navigation.tphp">
                                      <div class="form-group">
                                          <label for="name" class="col-sm-2 control-label">Name</label>
                                          <div class="col-sm-10">
                                              <input type="text" class="form-control" id="name" name="name" placeholder="First & Last Name" value="<?php echo htmlspecialchars($_POST['name']); ?>">
                                              <?php echo "<p class='text-danger'>$errName</p>"; ?>
                                          </div>
                                      </div>
                                      <div class="form-group">
                                          <label for="email" class="col-sm-2 control label">Email</label>
                                          <div class="col-sm-10">
                                              <input type="email" class="form-control" id="email" name="email" placeholder="example@domain.com" value="<?php echo htmlspecialchars($_POST['email']); ?>">
                                              <?php echo "<p class='text-danger'>$errEmail</p>"; ?>
                                          </div>
                                      </div>
                                      <div class="form-group">
                                          <label for="message" class="col-sm-2 control-label">Message</label>
                                          <div class="col-sm-10">
                                              <textarea class="form-control" rows="4" name="message"><?php echo htmlspecialchars($_POST['message']); ?></textarea>
                                              <?php echo "<p class='text-danger'>$errMessage</p>"; ?>
                                          </div>
                                      </div>
                                      <div class="form-group">
                                          <label for="human" class="col-sm-2 control-label">2 + 3 = ?</label>
                                          <div class="col-sm-10">
                                              <input type="text" class="form-control" id="human" name="human" placeholder="Your Answer" value="<?php echo htmlspecialchars($_POST['human']); ?>">
                                              <?php echo "<p class='text-danger'>$errHuman</p>"; ?>
                                          </div>
                                      </div>
                                      <div class="form-group">
                                          <div class="col-sm-10 col-sm-offset-2">
                                              <!-- Will be used to display an alert to the user -->
                                          <?php echo $result; ?>
                                          </div>
                                      </div>
                                 </form> 

或在HQL语句的子查询中调用UDF的任何其他方式。

1 个答案:

答案 0 :(得分:0)

流畅的hibernate具有构建映射SQL服务器用户定义函数的选项。

  

Map(o =&gt; o.Status).Formula(&#34; dbo.GetStatus(&#39; ID)&#34;)。ReadOnly();