Ich versuche, Daten im JSON-Format für das ich diesen Code Web-MethodeImplizit den Typ 'int?' zu 'int'
Format versuchen zu bekommen:
[{name: 'May',data: [23]}, {name: 'June', data: [43]}, {name: 'July', data: [45]}]
Code:
try
{
var data = new Datas1().spsumdata().Select(s => new { name = s.Month, data = new int[] {s.data} }).ToArray();
return Newtonsoft.Json.JsonConvert.SerializeObject(data);
}
catch(Exception)
{
throw new Exception();
}
aber dies zeigt eine Fehlermeldung:
Cannot implicitly convert type 'int?' to 'int'. An explicit conversion exists (are you missing a cast?)
Wenn ich gespeicherte Prozedur im Modell hinzufügen und dann Funktion im erstellen Port I wählen komplexen Typ
[EdmComplexTypeAttribute(NamespaceName="TrackDataModel", Name="spsumdata_Result")]
[DataContractAttribute(IsReference=true)]
[Serializable()]
public partial class spsumdata_Result : ComplexObject
{
#region Simple Properties
/// <summary>
/// No Metadata Documentation available.
/// </summary>
[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
[DataMemberAttribute()]
public global::System.String OwnerName
{
get
{
return _OwnerName;
}
set
{
OnOwnerNameChanging(value);
ReportPropertyChanging("OwnerName");
_OwnerName = StructuralObject.SetValidValue(value, true, "OwnerName");
ReportPropertyChanged("OwnerName");
OnOwnerNameChanged();
}
}
private global::System.String _OwnerName;
partial void OnOwnerNameChanging(global::System.String value);
partial void OnOwnerNameChanged();
/// <summary>
/// No Metadata Documentation available.
/// </summary>
[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
[DataMemberAttribute()]
public global::System.String Month
{
get
{
return _Month;
}
set
{
OnMonthChanging(value);
ReportPropertyChanging("Month");
_Month = StructuralObject.SetValidValue(value, true, "Month");
ReportPropertyChanged("Month");
OnMonthChanged();
}
}
private global::System.String _Month;
partial void OnMonthChanging(global::System.String value);
partial void OnMonthChanged();
/// <summary>
/// No Metadata Documentation available.
/// </summary>
[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
[DataMemberAttribute()]
public Nullable<global::System.Int32> data
{
get
{
return _data;
}
set
{
OndataChanging(value);
ReportPropertyChanging("data");
_data = StructuralObject.SetValidValue(value, "data");
ReportPropertyChanged("data");
OndataChanged();
}
}
private Nullable<global::System.Int32> _data;
partial void OndataChanging(Nullable<global::System.Int32> value);
partial void OndataChanged();
#endregion
}