Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两个 A 类和 B 类。当填充 A 类时,我已经获得了所有数据。B 类需要使用部分数据,我可以将 B 类安排为 A 类内部的私有对象。我不希望在填充 B 类时再次查询数据。如何让同一个查询填充 2 个类,或者是有没有办法将数据从 A 传递到 B?
如果 B 类只能包含 A 类的数据,那么你可以做一些类似的事情;
public class A { public string Field_1 {get;set;} public string Field_that_B_likes {get;set;} } public class B { public string Field_that_B_likes {get;set;} public B(A obj) { Field_that_B_likes = obj.Field_that_B_likes; } }