Named Update in WCF RIA Services

by abidins 12. July 2011 12:05
Domain services are Windows Communication Foundation (WCF) services that encapsulate the business logic of a WCF RIA Services application. A domain service exposes a set of related operations in the form of a service layer. When you define a domain service, you specify the data operations that are permitted through the domain service.
When designing a domain service, you should think of the domain service as a set of related tasks that you expect users to perform in your application. Typically, such tasks involve a small group of closely-related entities. For example, in an expense reporting application, you might expose entities for expense reports, line items, and details. You might, then, place entities for accounts and payments in a separate domain service[1].
Data Operations
You may add different data methods to a domain service that you want to expose like Query, Insert, Update, Delete. Besides these methods, you can also add more complicated operations, Invoke, Named Update. Named Update is to implement custom operations that do not fall into simple modification operations.
Convention
If you want to write a simple update method for ,lets say, Activity Entity, expected signature values should be as "public void UpdateActivity(Activity activity)".
It has to be like this for simple update operation for the Activity Entity. On the other hand, you can create an update method with different signature but some attribute has to be added to name of the update method. In that case, you dont have to follow the above convention. You can name your method as whatever you want. In below example, UsingCustomMethod attribute is set to true and as you noticed the name of the method is different.
 
And you can call this method in the code as follows;

So UsingCustomMethod attribute will give you the option to write more complicated operations.
References
 

How to Refresh User Control from another User Control in Silverlight

by abidins 10. May 2011 17:13

Refrehing the list or some other item in user control from child window is easy. All you need to do is wire up the child_closed event for child window and that s it. How about refreshing the list in another user control from this child window? There is no relation between the child window and the user control that we want to update. So, we cannot use child_closed event for that user control. Let s talk about the scenerio,

- Assigned Activites (User Control 1) , child window: CLM Activity

- Unassigned Activities (User Control 2)

- Activities ( User Control and it hosts UC1 and UC2)

What we want is, when we click ok button in "CLM Activity" child window, we will refresh UC1 and UC2.

- In Order to that,first, we ll define an event in assigned activities

- Then wire up this event to child window as follows. Child_Closed event is no longer need to be used

- Define OnPopupClosed event in assigned Activities user control. So, once the child window is closed, this event will be raised and Activities are refreshed in assigned activites screen.

- In Activities which is the host user control for the others, We ll wire up the same event handler for assigned activities.

- This event is also raised as well as OnPopupClosed event in Assigned Activities when the child windo is closed. RefreshSelf method refreshes the list in Unassigned Activities user control.

These are the steps to refresh the user control (unassigned activities ) from the other user control (assigned activities).

Adding a mouse over effect to an image

by abidins 18. April 2011 11:26

Expression Blend is a powerful tool. It will write the necessary code for you. It is very easy to add mouse over behavior to any kind of control with silverlight. In the below example, Our goal is to add "MouseOver" and "MouseLeave" behavior to an image. Here are the steps;

1.Write click over the file that you want to add behavior and select "Open in Expression blend..."

 

2.In the "States" tab of Expression Blend, click on "add states group" icon to create a visual state of the control.

3.Give a name to Visual State Group and specify the Default Transition

4. Click on Add State icon right next to Visual state group that you ve created and give a name to the state. If you notice, VisualState state recording is on. What ever the style you apply on the image is recorded in this period. When you done styling the image (ex: making the border thicker, making it invisible etc.) click on Base at the top to finish.

5. At the end we ll have two states defined (NormalSearch, MouseOverSearch)

6.Switch to Assets tab and in the Behaviors menu select "Go to State Action"

7. Drag and drop "Go to state action" over the image that you want to add behavior

8.Do the same thing for imgExpandHover image.

9.When [GoToStateAction] for imgExpand is selected go to properties at right side of the screen and select "MouseEnter" for event name and "MouseOverSearch" for State Name

10. For imgExpandHover  image,select "MouseLeave" as event name and "NormalSearch" for State Name

It will add all the necessary code automatically in .xaml file. We ve just created two states for two images. Initially, imgExpand is visible and imgExpandHover is invisible. In [GotoStateAction] part, events are defined for mouse enter and mouse leave behavior. What it does is, when you hover over the imgExpand, it ll be invisible and imgExpandHover image will be visible. When you do mouse leave from the image, imgExpand will be visible again and imgExpandHover will be invisible. imgExpandHover image has a border around it.So, when you mouse over the image you ll see that its border get thichker. That is basically what we wanted achieve.

Recent Posts