I want to add nested property when creating node in apache-age like nested dictionary in python.
You can do like this:
CREATE ({key_value: {nested_key: nested_value})
The syntax for creating a nested map is the same as the first map.
The syntax for creating properties in key-value form is
CREATE ({key : value})
Similarly you can nest it as deep as you need in your case in the following way
CREATE ({key : {nested_key : nested_value})
Related
I'm want to create a collection that will use my source blocks (there are many) as the key element to lookup a value. I want to use this collection as part of a inject function that will use the source name to get the value I need.
I'm wondering it will look like this:
int injectfunction = collectionName.get(SourceBlockName);
I'm open to hear about other more efficient methods.
I've tried using a LinkedHashMap with a Key element class "Other" then specified it as "Source" and the value element as int. I also tried Source, but in both cases it didn't work.
create a collection of type LinkedHashMap with key type String and value element class Source
Then you can populate your collection using this for example:
for(Object o : findAll(getEmbeddedObjects(),o->o instanceof Source)){
collection.put(((Source)o).getName(),(Source)o);
}
Then you can just use the name of the source to inject:
collection.get("source name").inject();
I am trying to subsequently manipulate the menus and tabs of a w2ui application.
In order to implement a generic solution, I added an additional attribute (zndesktop) to the related elements. Now I am looking for a generic method which gives me an array of all objects having this attribute.
Of course, I can hardcode such a query. But I am asking if there is an generic approach (for example w2ui.objects) which would return an array of all UI objects created for the application (recursive search)
w2ui objects are actually stored directly in the global w2ui object using their name, until you destroy them.
Example: if you create a grid with
$('#grid').w2grid({
name: 'my_grid',
...
});
Then you can access it with w2ui.my_grid or w2ui['my_grid'].
Of course you can also iterate the w2ui object (or rather its properties) just like any other JS object.
I'm using a web service which returns results like the following example:
{
"name":"Frank",
"meals":[
"cheeseburger",
"lasagne"
]
}
My Core Data schema looks like this:
Using MagicalRecord's MR_importValuesForKeysWithObject method, how would I set about mapping the meals key to the related Meals.name attribute?
I can map the meals manually after, using a for in loop, but just wondered if there was a way MR_importValuesForKeysWithObject would perform this for me?
Basically I want each object in the JSON "meals" array to become a new Meals entity.
Override importMeals: on the Person object and do the lookup/create/associate manually.
(longer answer)
every property imported via MagicalRecord calls import(PropertyName) on the target object, by implementing it you can override functionality.
I need a way to select objects given the name:string of the object and ObjectContext, but dont know how to do this.
I will use this to create a generic lookup dropdown editor template in ASP.MVC
So when view contains #Html.EditorFor (student=>student.School), it will show dropDown containing list of schools.
I get the target entity name from relation.ToMember, but don't know how to query data records with this input.
Currently I have added a custom method which gets string and returns innumerable and inside that I have a big switch case "School": return this.SchooleSet;
Is there a right way to do this.
I also want to add a generic method which allows me to query using syntax like ctx.Select<Teacher>().Where(...)
again here I have implemented with switch but there should be a better way to do this.
Try the CreateObjectSet method.
var q = ctx.CreateObjectSet<Teacher>().Where(...);
I am using this code to map a list of DTO's to their EF counterparts. I'd like to eliminate the loop, not to mention the fetch. The latter I can do by caching all Employee objects in a dictionary, but I'm stuck on the loop.
var gridEmps = (List<EmployeeDescriptor>) employeeDescriptorBindingSource.DataSource;
Mapper.CreateMap<EmployeeDescriptor, Employee>();
foreach (var newEmp in gridEmps)
{
var oldEmp = context.Employees.Single(emp => emp.Id == newEmp.Id);
Mapper.Map(newEmp,oldEmp);
}
As used above, AutoMapper maps from my DTO to an already instantiated entity object, but if I were to try this using two lists, like so,
var gridEmps = (List<EmployeeDescriptor>) employeeDescriptorBindingSource.DataSource;
var dbEmps = context.Employees.ToList();
Mapper.CreateMap<EmployeeDescriptor, Employee>();
Mapper.Map(gridEmps, dbEmps);
how will AutoMapper know how to link the correct objects from one list to the other, based on their key property? I know the key property is also mapped, but surely this will mess with the EF change tracking?
How can I tell AutoMapper to link source and destination objects by their key properties?
I have not found how to tell auto mapper collection merging rules without loops. My solution is following:
Create TypeConvertor: List<EmployeeDescriptor> -> List<Employee>
Mapper
.CreateMap<List<EmployeeDescriptor>, List<Employee>>()
.ConvertUsing(new EmployeeListConverter());
Put your loops inside Convert method of the EmployeeListConverter
Use Mapper.Map(gridEmps, dbEmps);