以下代码包含创建的过程。
public class HomeController
{
public HomeController() {
};
private IProcessingResult DoSomethingExpensive() {
// Lots of heavy processing
System.Threading.Thread.Sleep(300);
}
public ActionResult Index()
{
var result = this.DoSomethingExpensive();
// Do something with the result of the heavy processing
return View();
}
}
我无法使用存储过程,因为我收到了错误消息:
无法隐式转换类型' int'到了System.Linq.IQueryable'
我不知道如何从WebAPI中的表中返回数据。
以下是USE [SAMPLE_DB]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[GetAllGroups]
AS
BEGIN
SELECT [dbo].[QR_Groups].[Id], [dbo].[QR_Groups].[name], [dbo].[QR_Groups].[code]
FROM [dbo].[QR_Groups]
END
代码:
Controller
编辑:
新错误讯息:
无法隐式转换类型&System; System.Data.Entity.Core.Objects.ObjectResult'到了System.Linq.IQueryable'。存在显式转换(您是否错过了演员?)
答案 0 :(得分:0)
我从未在EF中使用存储过程,但我认为你想要的是这个
function generate_dateOfBirth()
{
$data = $this->input->post('data', TRUE);
if (!empty($data))
{
// Check if the ID Number supplied is not less than 13 characters
if ( strlen(trim($data)) == 13)
{
$year = substr($data, 0, 2);
$month = substr($data, 7, 2);
$day = substr($data, 4, 2);
$dateOfBirth = $year .'/'. $month .'/'. $day ;
echo $dateOfBirth;
}
else
{
echo 'You have entered Invalid ID number above';
}
}
}
$('#id_number').on('change', function()
{
var dob = $(this).val();
$.ajax({
url: '/generate_date',
method: 'POST',
data: 'data=' + dob,
cache: false,
type: 'json',
success:function(data){
//update Increase month
$('#dob').val(data);
}
}); //End of ajax call
}); $route['generate_data'] = 'Controller Name/function in the controller doesn"t contain html';