我有以下 BreezeController:
[BreezeController]
public class FinanceiraController : ApiController
{
readonly EFContextProvider<FinanceiraWS> _contextProvider = new EFContextProvider<FinanceiraWS>();
[HttpGet]
public string Metadata()
{
return _contextProvider.Metadata();
}
..... other functions
[HttpGet]
public List<RegraInfo> RegrasAProcessar(string dataRef, string marcaID)
{
try
{
DateTime data = DateTime.Parse(dataRef);
IQueryable<RegraInfo> lista = _contextProvider.Context.GetRegrasAProcessar(data, marcaID);
return lista.ToList();
}
catch (Exception e)
{
Console.WriteLine(e);
}
return null;
}
}
它公开了一个函数“RegrasAProcessar”,该函数应该调用在 entityframework edmx 文件中公开的 sqlserver 函数。正如预期的那样,sqlserver 函数“GetRegrasAProcessar”返回一个我想发回给客户端的 complexType。客户端依次声明了以下代码:
public partial class RegraInfo : BaseComplexObject
{
public Nullable<System.Guid> Id { get {return GetValue<Nullable<System.Guid>>();} set { SetValue(value); } }
public string Conta { get {return GetValue<string>();} set { SetValue(value); } }
public string Natureza { get {return GetValue<string>();} set { SetValue(value); } }
public Nullable<System.DateTime> UltimoProcessamento { get {return GetValue<Nullable<System.DateTime>>();} set { SetValue(value); } }
public Nullable<System.DateTime> DataProcessamento { get {return GetValue<Nullable<System.DateTime>>();} set { SetValue(value); } }
public Nullable<System.DateTime> ProximoProcessamento { get {return GetValue<Nullable<System.DateTime>>();} set { SetValue(value); } }
public Nullable<decimal> Valor { get {return GetValue<Nullable<decimal>>();} set { SetValue(value); } }
public Nullable<double> Qtd { get {return GetValue<Nullable<double>>();} set { SetValue(value); } }
public string Token { get {return GetValue<string>();} set { SetValue(value); } }
public string Parametro { get {return GetValue<string>();} set { SetValue(value); } }
public string MarcaID { get {return GetValue<string>();} set { SetValue(value); } }
public Nullable<System.DateTime> DataInicio { get {return GetValue<Nullable<System.DateTime>>();} set { SetValue(value); } }
public Nullable<System.DateTime> DataFim { get {return GetValue<Nullable<System.DateTime>>();} set { SetValue(value); } }
public string IdPeriodo { get {return GetValue<string>();} set { SetValue(value); } }
public string Descricao { get {return GetValue<string>();} set { SetValue(value); } }
public Nullable<bool> IsToken { get {return GetValue<Nullable<bool>>();} set { SetValue(value); } }
public Nullable<int> Ordem { get {return GetValue<Nullable<int>>();} set { SetValue(value); } }
}
期望接收类 RegraInfo 作为 complexObject。问题是当我用这段代码调用服务器函数时:
try
{
Dictionary<string, object> parametros = new Dictionary<string, object>();
parametros.Add("dataRef", dataRef.ToShortDateString());
parametros.Add("marcaID", marcaID);
var qry = new EntityQuery<RegraInfo>().From("RegrasAProcessar").WithParameters(parametros);
var results = await manager.ExecuteQuery(qry);
return results.ToList();
}
catch (Exception ex)
{
....
}
给出错误消息:“存在此名称的类型,但不是 Breeze.Sharp.EntityType”。这种方法有什么问题?我应该改变什么吗?我将不胜感激有关此主题的一些帮助。提前谢谢了。