I have a BCS model in SharePoint. This model has a single entity that should have multiple child entities of the same kind. I tried to associate the entity to self but the association does not appear on the entities' forms in the list. I expect to have a user experience that is similar to having a lookup field in a generic list that looks up to the same list.
How can I implement this?
Thanks.
The best solution I found so far is to create 2 different entities, create an association between them and make these two entities return data from the same source (in my case a .Net class).
Related
We're refactoring our solution to a Domain Driven Design structure. Our consultants which implement the software, should be able to customize some behavior of the application (for specific customers needs). For example they want to add custom defined properties to the presentation (user input forms) and save the custom data together with the entities defined in our DDD projects.
However, the domain objects should preferably not contain a customData property. I don't want to mix those and let the domain object know that there's something like custom data. I'm saving en fetching the entities by Repositories.
How do I make this scenario possible? One possible solution would be:
Query the entity by using his Repository
And query separately the CustomPropertiesRepository by entity ID.
Combine the two queries objects.
When saving the forms. It will be splitted again using two repositories
The disadvantage of this, is that I have to query twice though it should be one document.
Any advice on this problem?
in general dynamic properties are better suited for data-centric design and in my opinion this practice is not suitable for DDD.
in DDD the code must reflect the knowledge of the domain, it must be simple and explicit.
before thinking of the best way to persist a dynamic property, you must solve the problem at the design level:
1-There are three possible artifacts for a property: aggregate root, entity or object value.
2-usually a dynamic property brings with it a functional need (calculation, validation ... etc), where you will implement this functionality? whether in the aggregate root or in a domain service you will be compelled to compile your code and here the dynamic propriety loses its meaning, unless you think use a Business rules engine, and there you introduce another new paradigm with its whole complication, and some of your business logic would be outside aggregates and domain services.
I do not understand why pimcore would change the definition of class inheritance.
I want to create a class e.g. product with base information. From this, I want to create a new class e.g. Sneaker that inherits product - so that when i create a sneaker, it will have all properties of sneaker with inherited properties from product.
This doesnt work. It doesnt seem like this is what inheritance means in pimcore. I have read the pimcore documentation, but it doesnt explain clearly either. How would I go about the above need with pimcore 4 using the admin screens?
Thanks ~
Inheritance works only for the objects of the same Object Class. Inheritance in PIM sense means that the data is inherited in nested objects. It doesn't work in the sense of OOP class inheritance.
In short: only one object class should cover all of your products. Use Object bricks, Key value pairs, Classification store, relations, etc. to model all the different product types.
Class inheritances do not exist in pimcore. For example you have a sneaker and you want it to be added to the product category, this is not a piece of functionality that is supported by pimcore. You either place the sneaker product or if your scenario specifies creating the product category later, create a sneaker product with fake category. I am sure this behavior isn't very intuitive to people coming from more traditional OOP programming languages.
If you have any more misunderstandings, take a look.
I am following this example: Using NHibernate with ServiceStack
In the Contacts class library is there way to not have to create another Product class since we already have the Model or is this required? Seems like dependency injection could be used here.
Also could I move the model and mappings into thier own class library outside of the Services project?
How would I return model that had a property that was another model? I.e. Say we had an employee model that was linked to a person model by Id and the person model contained the employee Date Of Birth, I am not seeing how I would return that.
You don't have to create seperate models (or DTOs), however, I think when dealing with different ORMs the custom DTOs will make life easier. You can easily translate the properties with ServiceStack's property translater or something like AutoMapper.
I would create your DTOs in the manner that you want others to consume them. In other words you DTO's don't need to align with the underlying tables. You can combine models and flatten the data into useful DTOs. In your example the Employee class could expose the date of birth and any other person properties.
You can easily keep your DTOs in a separate project. I have done this in projects where I wanted to re-use the DTO classes elsewhere without including the services.
I am trying to use the Entity Mapping Model to migrate my existing many-to-many relationships in my application. I have the following relationships
Teams <<----->> Players
A Team entity can have multiple players, and a Player can be part of several teams. Now, I am trying to split this relationships to one to many by introducing a new entity with the following properties
TeamToPlayer
Team *team
Player *player
So the new relationship will look like
Team <--->> TeamToPlayer
Player <-->> TeamToPlayer
I am trying to figure what kind of entity mapping should be I be using to transform my core data model. Is it possible to do the above using the Mapping model or do i need to write code by inheriting NSMigrationPolicy class.
Any thoughts would be very helpful.
Thanks,
Javid
After trying to understand the migration process and entity mapping models for couple of days, I finally managed to find a solution. I was surprised to find how simple it was.
I created two entity mapping with Source from Player & Team to TeamToPlayer and mapped the relationships from the source entity to the destination entity relationship.
And updated the relationship mapping names in the PlayerToPlayer and TeamToTeam relationship mapping to use the new entity mappings.
Everything just worked.
This is only an example.
Say that you have 2 entities for 2 different context boundaries. The first context is the SkillContexter, the entity is 'Player' and has 3 properties: Id, Name and SkillLevel. In the other context (Contactcontext) the entity is 'Player' and has 3 properties: Id, Name and EMail.
How do I persist these entities to the database? I only want one table (Player) and not two tables (PlayerContact, PlayerSkill). Shall I have two different repositories for player that save the different context-entities, but into same table? Or shall I have a "master" player entity that holds all properties that I need to save, so that I create a new entity called PlayerMaster that has 4 properties: Id, Name, EMail and SkillLevel?
The first solution gives me more repositories, and the second makes me make a "technical" entity that only purpose is to save data to a database, and that feels really wrong, or is there a better solution that I have missed?
How have you guys solved it?
When I first started with DDD, I also wrestled with the Context + Domain + Module + Model organization of things as well.
DDD is really meant to be a guide to building your domain models. Once I stopped trying to sub-organize my Contexts and boundies, and started thinking of what really is shared between entities - things started to fit together better.
I actually do not use contexts, unless it is a completely different application (app = context). Just my preference. But, I do have Modules that only share base abstracts and interfaces common throughout code (IRepository, IComponent, etc). The catch is, DDD says that Modules can share entities between modules - but, only on a very limited scale (you really don't want to do it often).
With that in mind, I would get away from using contexts and move to a "what really am I trying to accomplish, what do these models have in common). Here's what I would think, reading your question (if I understand them).
Person() is a base entity. It has ID and Name.
PlayerSkill() is a Value Object, that is
accessable from Person().PlayerSkill.
Contact() is an entity that inherits Person(),
so it inherits ID and Name, and has additional Contact properties you want.
Now, I just tore up your domain. I know.
You can use a hybird approach as well:
Person() is a base entity. It has ID and Name.
Player() inherits Person(), applies Skill()
and other VOs.
Contact() inherits Person(), applies Address()
and other VOs.
I'm not quite sure what you mean by context boundaries, so my answer may be off.
Do the two Player entities represent the same physical entity (person)? If so, then I would create a single Player entity with all four attributes and store their data in a single table.