adding and filling a property to existing Core Data entity - objective-c

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.

Related

How to create just a view in odoo9 that does not save data in a model?

I am working in odoo9. Now I needed a view that permits the user to select partner and get his sale history.
Now I created a model "sale.history" but it saves the selected data as a record in db. I really don't need this.
How can I create a view for this.
Please also see this image.
You have two options for such views/reports.
Use TransientModel instead of Model for the model inheritance. Transient model records in database will be deleted by a frequently running cron job. The email message PopUp/Wizard is a nice example for that.
Write your own report (database view) for sales order. Actually there already is one report for that: Reporting/Sales/Sales Analysis. The model for that report is sale.report if you want to know, how it's done.
Aside from using a TransientModel (old api) or AbstractModel (new api)...you can simply set the store property of field to false, that way your field will never be persisted to the database, it will simply be a 'view field'.
class sale_history(model.Model):
_name='sale.history'
partner = fields.Many2one('res.partner', store=False)
The partner field will never get saved to the database
You can use store=False on the field in the model (as danidee suggested).
You can also overwrite the create method on the model.
Question - what is the purpose of the "sale.history" model? If it does not store any data at all then you may be better off creating a new view against "res.partner" rather than creating a new model.

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.

custom business logic in dataform in Silverlight 4

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.

How do I get NHibernate to save an entity if I assign it an ID, but generate one otherwise?

According to the REST philosophy, a PUT request should update the resource at a URL if it exists, and create it if it doesn't exist. So in other words, if I use the following URL:
PUT http://server/item/5
If an Item exists with an ID of 5, it will be updated. If an Item doesn't exist with an ID of 5, a new Item will be created with an ID of 5.
However, I'm using NHibernate for persistence, and I mapped my IDs as Identity. This means that no matter what value I assign the ID, NHibernate will replace it with its own when I save a new Item.
How do I get NHibernate to save an Item with the ID that I assign it, without changing the ID mapping to Assigned?
If you use Identity, the DB won't allow you to enter a value.
That said, if your DB has some special syntax to allow inserting with explicit values in Identity fields, you can implement your own generator, which I guarantee will be error prone, hard to debug, and not very useful. But it's possible.
Study everything in https://nhibernate.svn.sourceforge.net/svnroot/nhibernate/trunk/nhibernate/src/NHibernate/Id and start creating your Frankenstein :-)

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.