Comments (5)
Couldn't this be addressed with #513?
from mapperly.
@latonz Yes, that seems like it's the option 2 I described above.
That would do the trick!
from mapperly.
@latonz With getting to know Mapperly a bit better, and seeing that the current behavior is:
- You define a "main" map eg
public static partial MyClassDto ToMyClassDto(this MyClass o);
- You define derivations of the main map and Mapperly will automatically use the rules of the "main" map eg
public static partial List<MyClassDto> MapToList(this List<MyClass> o);
public static partial IQueryable<MyClassDto> ProjectTo(this IQueryable<MyClass> o);
I'd perhaps suggest that for consistency a ToExistingDto() type mapping should also fall under this same sort of behavior. ie no attribute needed and Mapperly will automatically use the rules of the "main" map.
from mapperly.
When needing a mapping from one type to another Mapperly always uses the default mapping. For your list and queryable examples this will happen as you described as Mapperly needs a mapping from MyClass
to MyClassDto
down the object tree. However, a ToExistingDto
mapping is a new root-level alternative mapping to the default mapping and often the user wants a different configuration for it, therefore I don't think automatically applying the same configuration is a good idea. It would also make the API less explicit and harder to debug.
from mapperly.
Closing in favor of #513.
from mapperly.
Related Issues (20)
- Disabled nullability and MapPropertyAttribute.Use results in invalid generated code HOT 6
- Compile error when switching from 3.5.1-next.1 to 3.5.1-next.2 or 3.5.1 HOT 4
- Not discovering map when parent takes generic type and is located on different assembly HOT 6
- Use UserMapping as global configuration HOT 1
- Support generic mappings HOT 2
- Unexpected IQueryable mapping when project's Nullable flag is set to "disable" HOT 3
- Using source object as source property and/or coalesce 2+ source props HOT 2
- Many to many relationship mapping makes the app crash and exit with "Access violation" HOT 2
- Allow the usage of external methods with `MapProperty.Use` and `MapPropertyFromSource.Use` HOT 1
- Rework GH Actions release process
- Support mapping from `Dictionary<string, object?>` HOT 1
- Map to nested existing target instances
- With multiple ObjectFactory methods in the same class Mapperly is choosing the wrong one. HOT 2
- RMG009 is reported for same-name target property even if the value is mapped to a different property HOT 6
- Emit more readable constructor mapping code HOT 2
- Add option to only set target properties if it is null or default value HOT 1
- Expression bodied mappers HOT 1
- New warning given when mapping to different type (regression from 3.5.1 -> 3.6.0) HOT 1
- Generic mapping for existing target object
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapperly.