I have 2 tables in database one of them is employee and the other one is city. I created ado.net entity data model from database. I took a employe and i can access city of these. I am using web service and have a webmethod which return List. I selected employees and called ToList() method. I can not access city name in presentation layer which feeds by web service (asmx not wcf), only access in ID of city. how can i solve this problem.
You can use .Include when retrieving your entity from EF to load navigation properties for your entity.
http://msdn.microsoft.com/en-us/library/bb896272.aspx heres the docs on .Include, if you have EF4.1 or above there is also a lambda version in an extension method which gives you type safety (Reference System.Data.Entity)
Related
In "Dynamics 365 Finance and Operations - Supply Chain", I am trying to find the entity name and its attributes that correlate with this:
Route details -> Description -> (Type, Description)
I have done OData queries against a number of different route-operations related entities and I cannot find where those 2 attributes live.
I found an answer to this over on the Microsoft forum. It turns out that writing to Route Details -> Type, Description is not a straightforward thing. Those 2 attributes are actually fields on the DocuRef table in F&O and it appears that there is no publicly exposed entity for that. And thus the fields cannot be populated via OData calls. So I have been looking into building an X++ function in the web service endpoint layer of the F&O model.
I am using PostgREST to expose DB entities to a Springboot app which consumes those.
I have two entities inside my DB which are Person and City.
I would like to save the Person entity and the City at the same time, if any of those two fails I would like the other one to not persist on the PostgREST.
I would like to achieve Transactional behaviour but on PostgREST. Is there any chance to achieve this natively from the tool or without programmatically delete the just created record on exception?
You could create a PL/pgSQL procedure that receives data from City and Person, and insert on both tables, and calls a ROLLBACK if anything fails.
Here are the docs with some examples:
https://www.postgresql.org/docs/11/plpgsql-transactions.html
Postgrest will expose the procedure in the /rpc/{function_name} endpoint.
Here are the docs:
https://postgrest.org/en/stable/api.html#stored-procedures
I am building service oriented system, with multiple services and application.
Current I am not sure how to handle DB references between resources from multiple services and databases.
For example, I have a users service, where I can define all users and their roles.
Next I have, products service, where I can define my products, their prices and other information.
I also have invoicing service, which is used to create invoices. This service will use information from previous two services. It will link products and users to invoice. Now I am not sure what is the best approach for this?
Do I just save product ID and user ID that it got from other two services, without any referential integrity?
If I do this, then I will have problem when generating reports, because at time of generation I will need to send a lot of requests to products service, to get names and prices of product in invoice. Same for users.
Do I create some table products in my invoicing application, and store name and price of product at the moment of invoice creation?
If I go with this approach, then in case that price or name of product changes, I will have inconsistent data across my applications?
Is there some well-known pattern for this kind of problem, that is what is the best solution.
Cross-service references in DB is a common challenge for Data integrity between multiple web services, And specially when we are talking about Real time access.
There is two approaches for your case :
1- Databases Replication across your servers
I suppose that you have each application hosted on a separate server, So i can name your servers as Users_server, Products_server and Invoices_Server.
In your example, your Invoice web service need to grab data from Users & Products Servers, in this case you can create a Replication of your Users Database and Products Database on your Invoices_server.
This way you can run your Join queries on the same server and get data from multiple databases.
Query example :
SELECT *
FROM UsersDB.User u
JOIN InvoicesDB.Invoice i ON u.Id = i.ClientId
2- Main Database Replication
1st step you have to replicate all your databases into one main server we can call it Base_server, which basically contain all your databases from all your services.
Then you can build an internal web service for your application to provide needed data in just "One Call", this answer your question about generating reports.
In other words, you will make one call to the mane Base service instead of making 2 or 3 calls to your separate services.
Note: As a Backend developer we use this organization as a best practice while building a large bundle based application, we create a base bundle and then create service_bundle which rely on the base bundle.
If your services are already live, we may need more details about the technology and databases type you using in order to give you a more accurate solution.
Just because you are using SOA doesn't mean you abandon database integrity. Continue to use referential integrity where your database design requires it.
At the service level, you can have each service be responsible for returning identity information for the entities which it owns. This identity information may or may not be the actual primary key from the database, but it will be used by the clients of the service as though it were the actual primary key.
When a client wants to create an invoice, it will call the User service and receive a User entity, which will contain a User Identifier. It will call the Product service and receive a set of products, each with a product identifier. It will then call the Invoice service to create an invoice, passing the user identifier and the product identifiers. This will likely return an invoice identifier.
You can (probably should) enforce the integrity making the productId and userId foreign keys in your invoice table. Then your DB makes sure the referenced entities exist. Reports should join tables, not query services for each item. I assume a central DB shared across the system.
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!
I want to implement restful web-services to query my database.
In Netbeans I did this:
- I created entity classes from my db
- I generated web-services from these entity classes
GET methods work fine when testing but I have some additional requirements. I dont want to query only by tables' id-s. Data needs to be retrieved also when some other parametres are entered.
For example I have a table:
Customer: id, name, address, country
Now I want to display all customers from a specific country.
Where in code can I achieve that?
You can do this with slightly different urls.
So for a single customer you'd present a URL such as:
GET /customer/123.html
But for multiple customers, you'd figure out a way to specify groups. If you wanted all customers, you'd go for:
GET /customers.html
But say you grouped by country, you could try:
GET /customers/Australia.html
Using the singular or plural form would separate the two types of get-requests.