C
C#2y ago
zikalol

❔ ❔ Better way to map object

Hello guys, i have an object called Room and it have building,floor,zone data
Data im getting
class room {
buildingProp1
buildingProp2
FloorProp1
ZoneProp1
Roomprop3
Roomprop4
}
//i want to generate multiple classes like that

//building
class row1 {
buildingprop1
buildingprop2
FloorProp1 = null
ZoneProp1 = null
Roomprop3 = null
Roomprop4 = null
}
//Floor
class row2{
buildingprop1
buildingprop2
FloorProp1
ZoneProp1 = null
Roomprop3 = null
Roomprop4 = null
}
//Zone
class row3{
buildingprop1
buildingprop2
FloorProp1
ZoneProp1
Roomprop3 = null
Roomprop4 = null
}
//room
class row4 {
buildingProp1
buildingProp2
FloorProp1
ZoneProp1
Roomprop3
Roomprop4
}
Data im getting
class room {
buildingProp1
buildingProp2
FloorProp1
ZoneProp1
Roomprop3
Roomprop4
}
//i want to generate multiple classes like that

//building
class row1 {
buildingprop1
buildingprop2
FloorProp1 = null
ZoneProp1 = null
Roomprop3 = null
Roomprop4 = null
}
//Floor
class row2{
buildingprop1
buildingprop2
FloorProp1
ZoneProp1 = null
Roomprop3 = null
Roomprop4 = null
}
//Zone
class row3{
buildingprop1
buildingprop2
FloorProp1
ZoneProp1
Roomprop3 = null
Roomprop4 = null
}
//room
class row4 {
buildingProp1
buildingProp2
FloorProp1
ZoneProp1
Roomprop3
Roomprop4
}
PS: ofc i rows 4 inherits row 3 and row 3 inherits row 2 etc.. i have done it with automapper I autoMap all rows to the row4 class then i aggregate the list to a tuple that contains lists of row 1 row 2 row 3 then i map them again to row4 class then i add them to the original list. Is there any better way to do it ? i have used aggregate to just generate all data with one loop
3 Replies
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
zikalol
zikalol2y ago
Up
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.