Using OrganizationServiceContext to update a different custom entity - dynamics-crm-2011

Can I use the existing OrganizationServiceContext for a plugin to update an entity other than the current target entity?

Yes, and if you're running pre or post transaction (not pre-validation) it'll be included as a part of the SQL transaction.

Related

What is the preferred strategy/workaround for introducing legacy database entities in Jhipster

Is there a good practice to introduce existing legacy database tables/entities into a JHipster project?
The idea I had was to create the JPA entities that look exactly like the existing entities and then use the generated artifacts as per normal. Will this possibly work?
In the end, I opted for just creating a view of all the underlying tables I needed in my query. The steps I followed were:
create the view on the DB,
Generate the entity using JHipster, with exactly the same fields.
Strip out the Update ad Create and Delete functions and we have a read-only view page with all the data you need and all the fields displaying, done.
Now I can add my own routers and buttons, to allow other specific operations/flow. This page was my inspiration: https://www.javabullets.com/calling-database-views-from-spring-data-jpa/

Bulk delete in Entity framework using Entity Sql

I want to implement bulk delete in Entity framework. I am planning to use Entity sql for that, but after a long search i am not able to find a single example of delete statement in Entity Sql. I dont want to use Sql statement also. Does Entity framework provide any bulk update without using For each loop internally ? I want to delete complete list of object in single transaction. Is it possible in Entity Sql ?
There is a nuget package that provides bulk delete/update that I know of.
Most people using entity framework do not use this because it bypasses any logic built in the model (no code executed in the savechanges override for example), but if you are only doing data retrieval/delete without any business logic this might help.

How to enable User able to see a custom entity record having N:N relationship

I have a custom entity Project, which is having a many to many relationship with User entity.My requirement is when an User is added to a Project he/she only can see that project.
To do that I have tried to add a custom Plugin which will share the Project record to added User, in update message of Project entity. But plugin not firing.
Is there any other way to do that? Please help me out here.
Thanks.
You need to register the step of your plugin at Associate message (and eventually Disassociate is you want to manage also when a Project record is removed from a User) not the Update one.
When a record is linked with a 1:N or N:N relationship the record doesn't get updated.
The Associate message needs to be registered against all entities (leaving empty or set to none the Primary Entity field inside Plugin Registration Tool)
If you use the Developer Toolkit you can find a tutorial to register on Associate message here:
http://zhongchenzhou.wordpress.com/2012/05/20/create-plug-in-for-message-with-no-primary-entity-associated-using-dynamics-crm-2011-developer-toolkit/
Read also this post that explains how to check the entities that triggered the plugin:
http://orwin.ca/2011/07/05/crm-2011-plugin-triggering-off-associate-message/

Automatically create record while creating a entity record

I have a project entity and a projectStages entity. I want, when a project record will be created automatically projectStages entities will be created for each stages.Till now I was doing it using plugin.
Just wanted to know if there is any way I within the CRM to do this.
this is a screen shot of the customer security roll.
Thanks.
I would do that using plugins, is there any reason you don't want to use plugins? You could use workflows to create projectstages when a project is created too, that will be asynchronous though.

Entity Framework Partial Entity Update

I am using Asp.net Webapi and EF and i am having issues with partial updates with the Entity Framework 5 .
I usually get say 20 fields from REST services that i need to update out of the complete entity.When I update I set the entity state to Modified.
The whole entity is updated all the time overriding all the existing values in the table that should not be changed as a result of the update.
There are random fields that I got from REST services not fixed fields that can help me to identify what properties are updated.
I want to know how this issue is being resolved out there and what are the practices are used to fix this.
Thanks.

Resources