custom business logic in dataform in Silverlight 4 - silverlight-4.0

I am using Domain Services and Entity Framework. EF has account entity with 4 fields, ID,Name,Age, MyLogic
in My sample XAML file:
i have 3 fields for example ID, NAME,AGE.
While inserting and updating data, i have 3 values on XAML file and i need to insert custom logic into 4rth field. like
MyLogic= Name-Age-ID( new auto generated id from database)= eg Adam-58-NewPKValue
What is best practice to solve it.
Thanks,
R

There are several ways to implement a 'pseudo' property (i.e., a value that is not stored in the database, but computed from other values instead). If you are using the MVVM pattern, you can bind the field on the data form to a notifying property in your ViewModel.
In order for the dataform to be in synch, the mutators for your other three properties would have to invoke the setter of your 'pseudo' property. So that, for example, when the user changed the Name, the NameAgeId property would be simultaneously updated.

Related

Validating against a duplicate entry in ASP.NET 5 MVC 6

Using asp.net 5, MVC 6, code first, entity Framework 7, beta 8.
I understand that some validation can be handled through annotations on properties, e.g. Data Type, min, max values and the jquery scripts, but I'm not sure how in code validation against a duplicate entry getting into the database, like preventing a duplicate e-mail reg on a form.
Is there any annotation that I can use for this on my model property or do I need to code something in my controller to handle this custom validation? Anyone got an example to share?
EF7 does not have any magic to prevent duplicate values in a table. The only way to validate duplicates is to make a roundtrip to the database. The best way to do this is with a unique constraint. This may be expressed as a unique index. Any attempt to insert a duplicate entry should throw an exception.
That said, you can configure EF7 to recognize the unique index in your database in your OnConfiguring method. See Indexes : Configuring Your Model in the EF7 docs.
modelBuilder.Entity<User>()
.Index(b => b.Email)
.Unique();

GemFire value change without refreshing all values

I m using (String, Arraylist of String) as the key value pair in gemfire caching.Is there any method to just add or delete a particular value from the value list without getting the entire list and add/delete and publishing the list again?!
You can create wrapper object to keep list. This wrapper object can implement delta interface. Using this you can add/delete field from list. See if this helps.
GemFire serializes the value when storing, and has various complex configurations to control the type and level of serialization.
Therefore, when you're updating a value in the value, what's happening is that the serialized value is being streamed to the client and then you're changing it and then re-serializing the changed value and streaming it to the server which is then storing it.
If you want to just update a value in the ArrayList on the server side itself, then you have to create a server-side listener and add that class to the server's classpath so you can manage the serialization/deserialization more finely.
Alternatively, you probably need to change your data model so that the ArrayList value is more like a Map, and is flattened to a secondary region colocated with the primary region, etc.

adding and filling a property to existing Core Data entity

So, many times before when I needed to add a property to an entity, I created a new version of xdatamodel file and performed lightweight migration, that automatically added this property to all already existing NSManagedObjects.
But now i need no only to add property, but also to fill it with a value, that can be calculated using another existing property.(Ex: I have an entity User with property "name", and now I need to add a property "hashname" = [user.name base64],so that all my existing users have this filled property)
So, is there a way to do it using migration? (I know that it's possible simply select all users without hashname and fill it manyally after lightweigt migration, but i want to know if migration technology provided by apple can do it for me)
You have to do it "manually". The only automatic filling of a property is with a default value, but that would not be dynamic.
You don't need to actually add calculated properties to the model. Just create an NSManagedObject subclass that includes this property and calculates it from its other attribues.

Cross model fetched properties

How do I implement cross-model fetched properties in a core data model? Simply put, let's say I have two models -- a CompanyStructure model that describes departmental hierarchy, and a Employee model that describes all employees. How would I set an employee's department as a fetched property?
I found a similar question asked here. It's a good description of the problem I'm facing:
When I setup a fetched property for state in my document entity (in
Xcode modeller) it needs the destination set – however, the
destination popup only shows entities in the current model. What I
want (I think) is a predicate something like:
State.id == $FETCH_SOURCE.state_id
in order to relate the document entity to the globally defined state
entity in the other model.
BTW, I don't know about $FETCH_SOURCE or $FETCH_ANYTHING_ELSE, so I don't really understand the code block in the quoted segment above. I do know that I can't set the entity for an employee's department fetched property because they're in separate models.
EDIT -- Merging the two data models into one is not an option.
Fetched properties are part of the model, so by definition they are not cross-model. If you want to refer to more than one model you have to do it in code. Also, the definition of the connection between the Employees and Departments can only be done within a model, unless you use your own UIDs and thus bypass the model metaphor.
They way I do similar tasks, I add additional .h and .m files to my classes, like ClassName+Additions.h and I declare "properties" as methods that can be called just like properties such as [smith department]. In these files, I can #include all the necessary classes from the other model and maintain separate managed object contexts.

Adding more promoted properties after a first one in BizTalk

I've got a BizTalk solution where I added a schema, and promoted a field
- this added the default PropertySchema.xsd with the element in
A bit later, added another schema, but when I try and promote a couple of fields, but when I select Show Promotions, I end up mapping the new field to one of the existing fields in the PropertySchema
My bad ... I should have used the Quick Promote
You can manually add items to the property schema as you would with correlation and then associate the promoted property.