Taking object without empty properties in Linq
I want to take pa
but empty MG
props.
Parent pa = new Parent()
{
MC = new Child[]
{
new Child() {M1 = 1},
new Child() {M1 = 2},
new Child() {M1 = 3},
},
MG = new GrandChild[]
{
new GrandChild() {M2 = "1"},
new GrandChild() {M2 = ""},
new GrandChild() {M2 = ""},
new GrandChild() {M2 = "4"},
开发者_运维技巧 },
MP = "just string prop",
};
I know this is not true but wanna take my object like this way:
var vv = pa.MG.Where(_p=>_p.M2!="").Select(_k=>_k.**parent**)
pa.MG = pa.MG.Where(gc => gc.M2 != "").ToArray();
精彩评论