English 中文(简体)
C#:是否有办法自动创建采集器和固定装置?
原标题:C#: is there a way to make the creation of getters and setters automatic?

I m 利用其正式C#司机撰写Mongo网络应用程序。

为了执行参考文件,必须用手工操作。

让我们这样说:

class User {
    ...
    public MongoDBRef Topic { get; set; }
}

选择我们所需要的专题如下:

db.FetchDBRefAs<Topic>(user.Topic);

创造新的目标:

user.Topic = new MongoDBRef(TopicsTable, topic._id);

我决定设立一个虚拟财产,使之更方便:

    [BsonIgnore]
    public Topic _Topic
    {
        get
        {
            return db.FetchDBRefAs<Topic>(Topic);
        }
        set
        {
            CreatedAd = new MongoDBRef(TopicsTable, value._id);
        }
    }

现在我可以这样说:

 user._Topic = someTopic;
 anotherTopic = user._Topic;

显然,对所有参考物体来说,这样做是巨大的痛苦。

是否有办法使这一进程自动进行?

增 编

最佳回答

页: 1 我怀疑视频演播室密码。 我从来没有这样做过,但我认为这恰恰是他们通常使用的那种东西。

问题回答

http://msdn.microsoft.com/en-us/library/ms165392.aspx”rel=“nofollow” 视觉演播室代码。

<代码>prop和两个表格的类型,你只需要填写财产的类型和名称。

s在背后领域的全部财产(propfull)、读取的财产(propg)和许多其他东西——例如空构体(ctor)。

你们也可以创建和使用自己的法典。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签