我正在开发Web API,我在返回数据时遇到错误;
无法隐式转换类型
我尝试修复错误但失败了,让我得到像你这样的伟大开发者的帮助。我会很感激。 以下是代码:
var a = ['','one ','two ','three ','four ', 'five ','six ','seven ','eight ','nine ','ten ','eleven ','twelve ','thirteen ','fourteen ','fifteen ','sixteen ','seventeen ','eighteen ','nineteen '];
var b = ['', '', 'twenty','thirty','forty','fifty', 'sixty','seventy','eighty','ninety'];
function inWords (num) {
if ((num = num.toString()).length > 9) return 'overflow';
n = ('000000000' + num).substr(-9).match(/^(\d{2})(\d{2})(\d{2})(\d{1})(\d{2})$/);
if (!n) return; var str = '';
str += (n[1] != 0) ? (a[Number(n[1])] || b[n[1][0]] + '-' + a[n[1][1]]) + 'million ' : '';
str += (n[2] != 0) ? (a[Number(n[2])] || b[n[2][0]] + '-' + a[n[2][1]]) + 'hundred ' : '';
str += (n[3] != 0) ? (a[Number(n[3])] || b[n[3][0]] + '-' + a[n[3][1]]) + 'thousand ' : '';
str += (n[4] != 0) ? (a[Number(n[4])] || b[n[4][0]] + '-' + a[n[4][1]]) + 'hundred ' : '';
str += (n[5] != 0) ? ((str != '') ? 'and ' : '') + (a[Number(n[5])] || b[n[5][0]] + '-' + a[n[5][1]]) + 'only ' : '';
return str;
}
console.log(inWords(999999999));
console.log(inWords(1095));
此声明:WHERE creation_date BETWEEN
CONVERT(VARCHAR(10), @DateFrom, 103)
AND
CONVERT(VARCHAR(10), @DateTo, 103)
给出错误,其他声明没问题。实际上它只是抱怨public IEnumerable<TABLE1> LoadSubIndustryByID(int id)
{
foreach (var subIndustry in Db.TABLE1.Where((u) => u.us_user_id == id))
{
var childIndustry = Db.TABLE2.Where((c) => c.sci_cat_id == subIndustry.sci_cat_id);
yield return childIndustry;
}
}
。
答案 0 :(得分:1)
当您使用TABLE2类型时,您的函数正在返回TABLE1的IEnumerable
。
您应该更改功能以返回IEnumerable<TABLE2>
答案 1 :(得分:0)
public IEnumerable<TABLE2> LoadSubIndustryByID(int id)
{
foreach (var subIndustry in Db.TABLE1.Where((u) => u.us_user_id == id))
{
var childIndustry = Db.TABLE2.Where((c) => c.sci_cat_id == subIndustry.sci_cat_id);
yield return childIndustry;
}
}
这样可行。