小编Gre*_*ski的帖子

如何使用Dapper.net Extensions忽略类属性?

我正在使用Dapper.net Extensions,并且想要忽略某些属性而无需编写完整的自定义映射器.正如您在下面的ClassMapper中看到的那样,当我真正想做的就是忽略一个属性时,会有很多冗余代码.实现这一目标的最佳方法是什么?

我喜欢这里提供的答案/sf/answers/1025454951/但我找不到定义'Write'的命名空间.

public class Photo : CRUD, EntityElement
{
    public Int32 PhotoId { get; set; }
    public Guid ObjectKey { get; set; }
    public Int16 Width { get; set; }
    public Int16 Height { get; set; }
    public EntityObjectStatus ObjectStatus { get; set; }
    public PhotoObjectType PhotoType { get; set; }
    public PhotoFormat2 ImageFormat { get; set; }
    public Int32 CategoryId { get; set; }

    public int SomePropertyIDontCareAbout { get; set; }
}


public class CustomMapper : …
Run Code Online (Sandbox Code Playgroud)

c# dapper dapper-extensions

5
推荐指数
1
解决办法
7273
查看次数

为什么我不能在 C# 中将“this”设置为值?

我正在使用 Dapper.net 扩展,我希望能够检索照片对象并将“this”设置为它,而不必单独设置每个属性。实现这一目标的最佳方法是什么?在下面的代码中,它说我无法分配给“this”,因为它是只读的。

public class Photo
{
    public Int32 PhotoId { get; set; }
    public Guid ObjectKey { get; set; }
    public Int16 Width { get; set; }
    public Int16 Height { get; set; }
    public EntityObjectStatus ObjectStatus { get; set; }
    public PhotoObjectType PhotoType { get; set; }
    public PhotoFormat2 ImageFormat { get; set; }
    public Int32 CategoryId { get; set; }

    public Photo(int pPhotoId)
    {
        Load(pPhotoId);
    }

    public void Load(int pPhotoId)
    {
        using (SqlConnection conn = new SqlConnection(Settings.Conn)) …
Run Code Online (Sandbox Code Playgroud)

c# dapper dapper-extensions

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

标签 统计

c# ×2

dapper ×2

dapper-extensions ×2