GET 和列表集合的 ServiceStack 路由
ServiceStack route for GET and List Collection
我想知道我是否可以用路由调用它?我可以毫无问题地从我的内部服务中调用此代码。我不知道如何在不添加 属性 来保存集合的情况下将集合发送到路由。换句话说,我可以调用 Route\API 并发送一个集合吗?
public void Post(List<InsertNotificationLogs> request)
{
var notifications = request.ConvertTo<List<NotificationLogs>>();
notifications.ForEach(x => x.AuditUserId = UserAuth.Id);
Db.InsertAll(notifications);
}
ServiceStack 中的所有请求 DTO 必须是单个非通用请求 DTO 具体类型。
从 Auto Batched Request Docs 开始,要定义接受 DTO 集合的请求 DTO,您可以从通用 List<T>
继承,例如:
public class InsertNotificationLogs : List<InsertNotificationLog> {}
public void Post(InsertNotificationLogs request)
{
var notifications = request.ConvertTo<List<NotificationLogs>>();
notifications.ForEach(x => x.AuditUserId = UserAuth.Id);
Db.InsertAll(notifications);
}
我想知道我是否可以用路由调用它?我可以毫无问题地从我的内部服务中调用此代码。我不知道如何在不添加 属性 来保存集合的情况下将集合发送到路由。换句话说,我可以调用 Route\API 并发送一个集合吗?
public void Post(List<InsertNotificationLogs> request)
{
var notifications = request.ConvertTo<List<NotificationLogs>>();
notifications.ForEach(x => x.AuditUserId = UserAuth.Id);
Db.InsertAll(notifications);
}
ServiceStack 中的所有请求 DTO 必须是单个非通用请求 DTO 具体类型。
从 Auto Batched Request Docs 开始,要定义接受 DTO 集合的请求 DTO,您可以从通用 List<T>
继承,例如:
public class InsertNotificationLogs : List<InsertNotificationLog> {}
public void Post(InsertNotificationLogs request)
{
var notifications = request.ConvertTo<List<NotificationLogs>>();
notifications.ForEach(x => x.AuditUserId = UserAuth.Id);
Db.InsertAll(notifications);
}