我正在尝试使用参数从C#调用AS400程序。目前我可以调用这样的程序
myRepository.Execute($"Call {Settings.As400ProgramLibrary}.EAPP100CL");
执行是我的IRepository接口的一部分
public interface IRepository<T> : IReadOnlyRepository<T> where T : class
{
void Add(T item);
void Add(IEnumerable<T> items);
void Attach(T item);
void EnrollInUnitOfWork(IUnitOfWork unitOfWork);
int Execute(string command, params object[] parameters);
IEnumerable<T> ExecWithStoreProcedure(string query, params object[] parameters);
IQueryable<T> FindBy(Func<T, bool> predicate);
IQueryable<T> FindBy(Func<T, bool> predicate, params Expression<Func<T, object>>[] includes);
void Remove(T item);
void Remove(IEnumerable<T> items);
void Update(T item);
}
如何在告诉它执行时添加参数? 我看了HERE,但想知道是否还有另一种方式。
答案 0 :(得分:1)
看起来您的调用字符串与您在AS400命令行上键入的字符串相同。如果是这样,那么您将在CALL命令上使用PARM关键字。
double[] xlist = {51.8, 10.3, 5.1, 2.6, 1.7, 1.29, 1.03, 0.86, 0.65, 0.52, 0.43, 0.37, 0.32, 0.29};
double x = 9.9; //or whatever declare x to equal
double high = xlist.length;
double mid = 0.0, low = 0.0;
while (low != high) {
mid = (low + high) / 2;
if (xlist[(int)mid] > x) {
low = mid + 1;
} else {
high = mid;
}
}
System.out.println(xlist[(int)mid - 1] + "\n" + x + "\n" +
xlist[(int)mid]);
在这个片段中,我添加了单引号以将参数作为带引号的字符串传递,这通常是最简单的,尽管您也可以将值作为其他类型传递,例如15,5十进制。我还明确添加了PGM关键字,虽然它通常没有它(就像你的调用字符串一样)。
有关进一步参考,请参阅CL手册:CALL command