Retrieving related data using edmx and repository pattern - repository-pattern

I am writing a simple mvc application with edmx and repository pattern.
I have the following table structure.
1) Employee
ColumnName:Name,ProjectCode
2) Project
ColumnName:Code,ProjectName
There is only data relationship between these two table,no association is defined in database between them.
I have to display projectname in list view of Employee in place of projectcode. So I have retrieve ProjectName from Project table for every entry of projectcode in Employee.
I have already created a repository class for employee.
What is the best and easiest way implement this requirement? I would prefer not to create a repository for Project entity just for retrieving ProjectName column value for provided code.

You can use Generic Repository pattern instead of creating each of repository.Using that either way you can query the context and navigation property do the rest of the things for you.
Following links will explain the implementation of generic repository pattern.
Here
Here

Related

Creating new data entity for RecId

I need to get product URL of commerce via Data Export - however I have not found a way of getting expect building it from store domain and product RecId.
I created a new data-entity and drag&dropped RecId from the entity I inherit - but it still does not appear in the csv export/mapping.
Any ideas how to achieve this task?
I solved it by adding field to staging table and creating mapping with RecId.

Create a doctrine repository class without an entity

I'm currently in a situation where I need to create a Repository class which would contain multiple financial statistic queries. The queries are not exactly tied up with one Entity but rather with multiple Entities and will select specific data from the database, based on various some conditions.
Having said that, I'm looking for a way to create a Repository class (i.e. StatisticsRepository) which is not associated with an Entity at all, so I could store the queries there. Simply creating that repository doesn't seem to be working. I'm guessing I probably need to create a service of some kind that loads this repo class? Is this correct, and if so is there an example I'm missing in the Symfony/Doctrine docs?
You can just create a class like StatisticsService/StatisticsFinder (naming convention is for you).
That service should have an entity manager injected, so define it in your config.
Create a query builder inside that service, then simply get and return results.

DropLink datasource item reference with custom dataprovider in Sitecore

How do bind a DropLink using a custom dataprovider?
More info:
I am trying to build a product catalogue site using Sitecore. Each product in the sitecore content tree can have a star rating and short text review attached to it (which will be linked to a user extended with a profile provider but that is another question).
I am planning to store the review information in an external database and reference it using a custom dataprovider. I have downloaded the NorthwindDataProvider from the Shared Source (here) and have altered it to use a table which contains the rating, text and a uniqueidentifier field to store the ID of the product from in sitecore the review is attached to.
The template field is a droplink and the datasource is set to the products in the catalogue.
When I edit a review in the custom dataprovider using the sitecore content editor, the droplink states 'Value not in selection list' even if I select one of the populated products and save using sitecore.
It is saving the ID in the database but if I look at the raw value it displays the id without the curly brackets. Working droplink fields' raw values appear to contain the brackets.
To create a review, I am using a jquery post to a webservice which writes to the database using an external datacontext. Should I be using some Sitecore API to use the custom dataprovider instead?
Any information using custom dataproviders would be helpful. The documentation I've been able to find has all stated what can be done but I'm struggling to find actual implementation.
So the first thing is that you have a template field and you're using droplink which is going to store the guid for the item selected. I'm not quite clear on whether or not you're pointing the datasource to a Sitecore item or not.. but that's essential if you're using droplink. Here's what I would suggest instead for the most straight forward way to do this:
Create a template that you add fields to handle the logic dealing with your catalog items. How you do that is your choice and Sitecore doesn't care since its only going to deal with the item and all it cares about is finding an item... you write business logic to manipulate the external data.
Once you have a folder that stores your catalog items, you could easily write a script to be triggered by the Rules engine in Sitecore or a Sitecore task that runs regularly to get your catalog items to add/update or remove the corresponding list of Sitecore items.
Also, another option that is more complex to implement, but if you have multiple data sources on your site, is a valid approach, is to use an object framework (like the Entity framework) as a data object layer that allows you to create and populate common objects with from any data source.
Hope this is helpful!

Is it possible to include a database view in a JPA/EclipseLink CriteriaQuery?

I am working on a project that needs to be able to create dynamic queries into an H2 database. This also includes a full text search with built-in H2 logic, tables, and triggers.
I have been trying to figure out how to add that full-text search into my CriteriaQuery but keep running into the road block that the tables used aren't entities in my model. I could add them as entities, but I don't want them created automatically by EclipseLink when a new database file is created since there is a function in H2 that creates the tables and does other necessary housekeeping.
I had tried the path of creating a view to query the full text tables to give me the information I need in the format I need. But I still keep running into the same problem that that view is not an Entity.
Has anyone encountered this situation before and/or figured out a way around it?
Thanks!

How to use CopyIntoItems to copy files into existing doclib items

This is my scenario: I need to copy files to a sharepoint document library using its web services and set metadata on them. That's all possible with CopyIntoItems (from Copy webservice) except for Lookup fields. CopyIntoItems ignores them, so i need another way to set data on those fields.
I've tried to create a list item with the mandatory and lookup fields metadata and then, using the item ID (creating a FieldInformation field with the ID, as well as some other simple metadata), called the CopyIntoItems method and, instead of updating the item, sharepoint created a new one.
I can't do this in the reverse order because i have no way to get the ID from the item created by CopyIntoItems...
So, the question is: How can i upload a file to a sharepoint document library and set all its metadata? Including Lookup fields.
Use a regular PUT WebRequest to to upload the document into the library
Query the document library to find the ID of the item you just uploaded (based on path)
Use the Lists.asmx web service to update the document metadata
Helpful link: Uploading files to the SharePoint Document Library and updating any metadata columns
Keep in mind that if the destination folder item count + the ancestor folders item count exceeds the list view threshold then you can't query the list for the id (step 2 from Kit's answer).
Queries can be done more efficiently if constrained to a particular branch in the folder hierarchy. A workaround would be to modify the site settings, but the queries would be sluggish and would make the solution less portable because the threshold for Office365 and BPOS can't be changed.
This explains it much better: http://office.microsoft.com/en-us/office365-sharepoint-online-enterprise-help/create-or-delete-a-folder-in-a-list-or-library-HA102771961.aspx