本文介绍了在实体框架中设置为属性的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个班级,例如
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?
推荐答案您可以将field1和field2声明为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
更多推荐
在实体框架中设置为属性的属性
发布评论