在实体框架中设置为属性的属性

编程入门 行业动态 更新时间:2024-10-20 01:29:09
本文介绍了在实体框架中设置为属性的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有两个班级,例如

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

更多推荐

在实体框架中设置为属性的属性

本文发布于:2023-11-13 02:04:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583113.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:属性   设置为   实体   框架

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!