小编san*_*des的帖子

如何处理默认日期时间

我有DAL,我将数据库空值转换为它们在C#中的等效表示.例如:

NULL for Numeric = 0
NULL for String = String.Empty
NULL for DateTime = "1/1/0001" (i.e. DateTime.MinValue)
Run Code Online (Sandbox Code Playgroud)

对于日期而言,问题在于表示层,尤其是在GridViews中.您无法1/1/01向用户显示.

我以前做的是检查if myDate.Year=1 or myDate.Year < AcceptedDate并显示空字符串,但与其他类型不同,似乎是额外的努力

请接受更好的方法.谢谢.

c# database asp.net data-formats

6
推荐指数
2
解决办法
1万
查看次数

在RxJava 2.x中使用flatMap

我正在使用自己的API,我希望使用RxJava链接一些分页结果.我使用基于游标的分页.(想象有50个用户):

{
    "data":{
        "status":"ok",
        "total":988, //users total
        "has_next_page":true,
        "end_cursor":"AQAxd8QPGHum7LSDz8DnwIh7yHJDM22nEjd",
        "users":[{"id":"91273813",
                "username":"codergirl",
                "full_name":"Code Girl",
                "picture_url":"https://cdn.com/21603182_7904715668509949952_n.jpg",
                },
                ...
                ]
        }
}
Run Code Online (Sandbox Code Playgroud)

现在,我正在使用改造这样的前50个结果:

public class DataResponse {
    @SerializedName("end_cursor")
    private String end_cursor;

    @SerializedName("users")
    private JsonArray users;

    @SerializedName("has_next_page")
    private Boolean has_next_page;

    public boolean hasNextCursor(){
        return has_next_page;
    }
    public String endCursor(){
        if (hasNextCursor()){
            return end_cursor;
        }
        return "";
    }
    public JsonArray getUsers(){
        return users;
    }
}
Run Code Online (Sandbox Code Playgroud)

然后:

public interface MyService  {
    @GET( "/users")
    Observable<DataResponse> getUsers(
            @Query("cursor") String cursor,
    );
}
Run Code Online (Sandbox Code Playgroud)

MyService service = RetrofitClient.getInstance();
service.getUsers() …
Run Code Online (Sandbox Code Playgroud)

pagination android retrofit flatmap rx-java2

4
推荐指数
1
解决办法
1078
查看次数