在实体框架中设置为属性的属性 [英] Set as properties to a property in entity frame work

查看:57
本文介绍了在实体框架中设置为属性的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有两个班级,例如

Hi,

I have two class like

Class prop{
public string status {get; set;}
public string value {get; set;}
}







and

Class DataFields
{
public string field1 {get;set;}
public string field2 {get;set;}
|
|

}



现在我要设置诸如
的属性
field1.status ="A";
field1.Value ="ABC";
field2.status ="N";
field2.value ="XYZ";

当我绑定值时,我将只绑定field1.value或field1.status.
所以,请您让我知道如何创建实体并将其分配给实体吗?



Now I want to set properties like

field1.status="A";
field1.Value="ABC";
field2.status="N";
field2.value="XYZ";

When I am binding the value I will just bind with field1.value or field1.status.
So can you please let me know how can I create and assign values to entities?

推荐答案

您可以将field1field2声明为class prop这个

You would declare field1 and field2 as class prop like this

public prop field1 { get; set; }
        public prop field2 { get; set; }




然后像这样低估他们:-




and instatiate them like this :-

field1.status = "A";
            field1.value = "ABC";
            field2.status = "N";
            field2.value = "XYZ";



希望对您有帮助



Hope that helps


这篇关于在实体框架中设置为属性的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆