using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using Dapper;
namespace Calculate.Models
{
public class SelectedDetailsGetter
{
SqlConnection con = new SqlConnection("Data Source=CHANDAKG-01-L\\SQLEXPRESS;initial catalog=Calculator;integrated security=true");
public IEnumerable<SelectedDetails> GetSelectedDetails(string Name)
{
string query = "SELECT * FROM DataNorm WHERE [email protected] AND year(DateMonth)=2014";
var result = con.Query<SelectedDetails>(query,new { name = Name });
return result;
}
}
}
このクエリは常にnullを返します。何か間違っていますか?誰もが使用することができますSingleOrDefault()
このダッパークエリは常にnullを返します
'GetSelectedDetails'は' null'を返すか、 'SingleOrDefault'を呼び出すと' null'を返すと言っていますか? – juharr
GetSelectedDetails()はnullを返します。 –
実際のプロバイダ名を「名前」に渡していますか? Provider = 'whomever'を使用してSSMSでそのクエリを実行すると、データが返されますか?私はあなたが何かを渡さないと、クエリによって何も返されないと仮定しています。クエリをデバッグします。それが "結果"のためにどのように生産されているかを見てください。また、 "SelectedDetails"の小道具はSQL列と同じ名前ですか? – Ethilium