I have a Project that use EF 5.0, is data base first. I would like to pregenerate the views, so I try to use this temaplate:
Template
However, how I have one library that has the edmx and the reposutory and I have another assembly with my POCO entities, so the library that implements my repository has a reference to the assembly that has the POCO entities. But this is a problema, and I read a solution by Scott Stafford:
solution
In this solution he says:
"To work around this, I made up a new entity and put it in the context's assembly, and listed it as the first DbSet. Now it picks it up, and works well (except that this is ridiculous)."
However, I don't know where to create a new entity. This new entity must by in my library the has the edmx or in the assembly that has the POCO entities? Is it not needed to modify the template .tt?
Thanks.
Related
According to apple doc's Persistent Store Types and Behaviors, the built-in persistent store types of core data are
1. XML
2. Binary
3. SQLite
4. In Memory
My Question is,
Among these which is the default store type when we use core data model in xcode and how can we change it
Well, NSPersistentStore is an abstract base class. One of its four subclasses must be deliberately created in code. So, there is not really a default store type.
There is, however some template code which gets generated when you choose one of the New Project or New Target templates in Xcode. In the current version (Xcode 10), when you switch on the Use Core Data checkbox, you get in the AppDelegate implementation a lazy var persistentContainer property which provides a singleton NSPersistentContainer object. This is by default the store you will use in the new target. But what store type is that? Well, the persistent store(s) of a NSPersistentContainer are specified in its persistentStoreDescriptions array property. By default, this array contains one persistent store of type SQLite, backed by a file in the Application Support folder of your app's container. This is, in a round-about way, the default store type you asked about.
The procedure to change this store type is explained in the Discussion section of the documentation of NSPersistentContainer.persistentstoredescriptions.
So you see the default is actually in the Xcode Project Templates. To get what you want, you can place the code you wrote after reading that documentation into a new Project Template and add it to your ~/Library. You can either override one of the default Project Templates, or create your own with a new name. A basic example is given in this blog post by Jake Craige. If that is not enough for you, Keith Harrison has published a quite thorough reverse engineering of Xcode Project Templates.
It's easier to generate tables and default classes with liferay's service builder.
But it is bit difficult for me to understand the hierarchy of classes generated by it.
Also the exact use of each class other than modifying LocalServiceImpl class as per our need by adding our own functionality.
I have gone through Service Builder doc. So I got some basic knowledge but would like to get more on this.
Even the link "Liferay Service Builder" was useful but outdated with current Liferay version. So Does anyone have update on above link or nice info explaining hierarchy with example/diagram?.
Any help is appreciated.
Thanks.
To implement the foreign key concept in liferay, you have to apply your own coding logic since the implementation of FK are not available in service builder. So I guess you need to put some code.
Read some forums related to service builder on liferay website. It will give you better exposure.
Read Liferay In Action. It is a good book
Here is What I obeserved In Liferay 6.1.
com.liferay.portlet.p_name.model:
This has interfaces and classes related to (table entity related to) this portlet.
For example com.liferay.portlet.announcements.model will have
Interfaces:
AnnouncementsEntry
AnnouncementsEntryModel
AnnouncementsDelivery
AnnouncementsDeliveryModel
AnnouncementsFlag
AnnouncementsFlagModel
Classes:
And In classes section, You will find wrapper classes and soap classes for each entity like:
AnnouncementEntryWrapper
AnnouncementEntrySoap
AnnouncementFlagWrapper
AnnouncementFlagSoap
AnnouncementDeliveryWrapper
AnnouncementDeliverySoap
Also for few Entity, you will find Classes for Constant entries like
AnnouncementsEntryConstants, AnnouncementsFlagConstants etc.
com.liferay.portlet.p_name.service:
This has classes and interfaces related to (table entity related to) this portlet.
For example com.liferay.portlet.announcements.service will have
Interfaces:
AnnouncementsEntryService
AnnouncementsEntryLocalService
AnnouncementsDeliveryService
AnnouncementsDeliveryLocalService
AnnouncementsFlagService
AnnouncementsFlagLocalService
Classes:
And In classes section you will have Util and Wrapper classes.
AnnouncementsEntryServiceUtil
AnnouncementsEntryServiceWrapper
AnnouncementsEntryLocalServiceUtil
AnnouncementsEntryLocalServiceWrapper
and so on.....
So In short following is the structure I observed in Liferay
[In Model, I:+Model,(ModelName), C:Soap, Wrapper and Constants]
[In Service, I:Service,LocalService ; C:ServiceUtil,ServiceWrapper,LocalServiceUtil and LocalServiceWrapper]
[In Persistence, I:Finder(BlogsEntryFinder),Persistence(BlogsEntryPersistence); C:Util(BlogsEntryUtil, BlogsEntryFinderUtil)]
Note:
I --> Interface
C --> Class
I have an iPad app, built with XCode 4.5, Storyboard, Core Data (using MagicalRecord) and iOS 6. I have two Entities, each with multiple attributes. The first entity has a one to many relationship with the second entity.
In the MagicalRecord docs, I don't see how to persist the data to the second entity; I read somewhere that Core Data generates it's own key and indexes. I know from past use of SQLite that I would need to set the key from the first entity to be able to access the second entity.
[UPDATED] Here is the modified code but it doesn't work either. I have previously selected a row in didSelectRowAtIndexedPath in another class. I assume that set the localContext. Any ideas why this is not working?
- (IBAction)saveAppointment:(UIButton *)sender {
AppointmentInfo *newAppointment = [AppointmentInfo MR_createInContext:localContext]; // create the entity
newAppointment.aStartTime = selectedStartDate;
newAppointment.aEndTime= selectedEndDate;
[localContext MR_saveNestedContexts];
}
You need to create your Entity in the proper (ie. localContext) context:
[AppointmentInfo MR_createInContext:localContext];
I found the problem... seems that I had the store setup incorrectly... I removed the parent pointer from AppointmentInfo and added the "class" information. Works like a champ now... thank you for your time, tho'.
I have a simple SharePoint 2010 BCS solution where I define two entities and a simple parent-child relationship between them. I happen to have entity classes (Parent and Child) in a separate assembly from my service classes (ParentService and ChildService). This doesn't seem to present a problem when using just Finder and SpecificFinder methods, but when I try to execute an AssociationNavigator method it fails. When my entity types are in the same assembly as the BCS model definition and associates service classes, the AssociationNavigator works fine. I am calling the AssociationNavigator like this:
var entity_instance_collection = new EntityInstanceCollection(1);
entity_instance_collection.Add(parent_entity_instance);
var association = (IAssociation)parent_entity.GetMethodInstance("ParentToChildAssociationNavigator", MethodInstanceType.AssociationNavigator);
var child_items = child_entity.FindAssociated(entity_instance_collection, association, lobi);
When the entity types are in a separate assembly, I get an InvalidMetadataObjectException when trying to execute FindAssociated:
Cannot load Type described by TypeDescriptor TypeName
'BdcModelProject2.BdcModel1.Parent, BdcModel1' on Parameter with Name
'parent' on Method with Name 'ReadItem' on Entity (External Content
Type) with Name 'Parent' in Namespace 'BdcModelProject2.BdcModel1'.
with this InnerException:
Could not load type 'BdcModelProject2.BdcModel1.Parent' from assembly
'BdcModelProject2, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=50bc5a1f7318bdeb'.
So, it seems that my app is just trying to load my entity types from the assembly where the BCS model is defined (BdcModelProject2) rather than the assembly where my entities are actually defined (ClassLibrary1). I have a few points of confusion about this:
I see that the BCS model has TypeName attributes in the TypeDescriptors that describe the types of the classes that implement the entity classes, but the Finder and SpecificFinder methods seem to function properly for me even when gibberish is supplied here, yet the AssociationNavigator fails to load the type. Why is this?
I don't see anywhere in the Visual Studio-generated bdcm file or in the MSDN docs for a TypeDescriptor that indicates where an assembly name can be specified for the entity types.
So, how can I use entity types in my BCS project when those entities are defined in a different assembly?
There are two possibilities here:
It does not find the dll
It finds an old version of the dll, that does not contain the new code that you are using
We have often had a problem that an old version is in the GAC. When a new version is installed in the bin directory, it just ignores it and continues using the version in the GAC. Then you delete the version in the GAC, but it still does not work, since it has cached the old version. Finally an IIS reset or a machine restart gets it working.
Short answer: Try and find an old version of the dll on the machine.
Edit
You could use a tool like Assembly Binding Log Viewer to track down the problem.
see: http://msdn.microsoft.com/en-us/library/e74a18c4(v=vs.90).aspx
In the book .NET Domain-Driven Design with C# from Tim McCarthy there's an example of a link table (two foreign keys + one boolean column) that gets it's own class in the domain. Is this common?
The example is a Contact table and a Project table. The link table is a ProjectContact. What are the pros and cons of using a class ProjectContact instead of having a List of Contacts property in the Project class and a List of Projects property in the Contact class?
I must say that having a ProjectContact class makes it easy to persist a new link between a Project and a Contact... but it seems overkill to me.
Pragmatically spoken (I'm not a DDD expert), I would say that a link table shouldn't pop up in the domain unless it is an entity on it's own (i.e. you need to attach behaviour to it, or it has properties other than the foreign keys).