我是一名.Net开发人员,用于在Microsoft Technologies上开发Web应用程序.我正在努力教育自己了解Web服务的REST方法.到目前为止,我喜欢ServiceStack框架.
但有时我发现自己以一种我习惯使用WCF的方式编写服务.所以我有一个问题让我烦恼.
我有2个请求DTO,所以有2个这样的服务:
[Route("/bookinglimit", "GET")]
[Authenticate]
public class GetBookingLimit : IReturn<GetBookingLimitResponse>
{
public int Id { get; set; }
}
public class GetBookingLimitResponse
{
public int Id { get; set; }
public int ShiftId { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public int Limit { get; set; }
public ResponseStatus ResponseStatus { get; set; }
}
[Route("/bookinglimits", "GET")]
[Authenticate]
public class GetBookingLimits : IReturn<GetBookingLimitsResponse>
{
public DateTime Date …Run Code Online (Sandbox Code Playgroud) 我想用Orqlite的SqlExpressionVisitor编写一个使用null cheking参数查询表的方法这是我的方法:
public static List<UserChatsDTO> GetUserChats(int startRow, int rowCount, DateTime? startDate, DateTime? endDate, string operatorName, short? rating, string visitorName)
{
using (IDbConnection db = DbFactory.OpenDbConnection())
{
SqlExpressionVisitor<UserChatsDTO> ev = OrmLiteConfig.DialectProvider.ExpressionVisitor<UserChatsDTO>();
ev.Where(q =>
(startDate.HasValue && q.Dated >= startDate) &&
(endDate.HasValue && q.Dated <= endDate) &&
(!string.IsNullOrEmpty(operatorName) && q.TakenByUser.Contains(operatorName)) &&
(rating.HasValue && q.Rating == (short)rating) &&
(!string.IsNullOrEmpty(visitorName) && q.VisitorName.Contains(visitorName)));
//ev.OrderBy();
ev.Limit(startRow, rowCount);
return db.Select<UserChatsDTO>(ev);
}
}
Run Code Online (Sandbox Code Playgroud)
但是Object引用未设置为对象的实例.当我调用ev.Where部分时抛出NullReferenceException.
这里有错误还是我错过了什么?谢谢.