Retrieving metadata using breeze is taking too long

Using breeze in my MVC 4 application to fetch data from a remote SQL Server database with about 40 entities. Surprisingly, the loading of metadata is taking longer than expected, ranging between 14s and 35s even though the size is just around 600kb.

However, once the metadata is loaded, fetching entities seems to be much quicker. For instance, an entity of 2.5 Mb was fetched in just 2.5 seconds.

Here is an image showing the loading process.

I'm curious to know why the initial loading is slow and if there are any techniques I can use to speed up the process?

Answer №1

Instead of constantly requesting server metadata, I take a different approach. I efficiently extract the metadata from an EntityManager's metadata store and save it in a JavaScript file as a global variable. This file is then included with my other scripts on my index.html page. When my application launches, I load this variable into my manager's metadataStore.

As time goes on, I enhance my process by automatically regenerating the metadata when the server starts, serializing and storing it in browser local storage, and more. Understanding that metadata is simply a JavaScript object opens up endless possibilities for innovation and clever solutions.

Answer №2

To streamline the process of loading metadata without an additional network call to the server, embed it in your scripts and supply Breeze with it manually as recommended by @Ward.

Below is an example using TypeScript:

import { DataService, EntityManager, MetadataStore, NamingConvention } from "breeze-client";

        // Your metadata object
        const metadata: any = Metadata.value;

        // define the Breeze `DataService` for this app
        const dataService: DataService = new DataService({
            serviceName: "http://localhost:63000",
            hasServerMetadata: false  // avoid requesting metadata from the server
        });

        // create the metadataStore 
        const metadataStore: MetadataStore = new MetadataStore({
            namingConvention: NamingConvention.camelCase // utilize this convention if needed
        });

        // initialize it from the application's metadata variable
        metadataStore.importMetadata(metadata);

        const entityManagerConfig: EntityManagerOptions = {
            dataService: dataService,
            metadataStore: metadataStore
        };

        this.entityManager = new EntityManager(entityManagerConfig);

You now have an EntityManager instance configured with the metadata and prepared to handle queries confidently.

For further details, refer to the official documentation

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Struggling to comprehend the filtering arguments in VueJS?

While going through the VueJS Filter(orderby) API documentation, I came across some confusion regarding the arguments. Below is a sample for reference: Arguments: {String | Function} targetStringOrFunction "in" (optional delimiter) {String} [...s ...

Three Divs stacked on top of each other, with varying heights based on

I am seeking a solution for creating a layout with three vertically stacked divs. The top div must have a fixed height of 60px. The middle div might contain content exceeding its height, therefore we've set it to overflow: auto. But regardless of th ...

Changing the color of dots in a React Material-UI timeline

Hey there, I'm trying to change the default color of the MUI TimelineDot component. I attempted to do so by adding this code: <TimelineDot sx={{ '& .MuiTimelineDot-root': { backgroundColor: '#00FF00' }, }} /> Unfortunate ...

Implementing pagination with complete page information using node.js and mongodb

Hello, I am currently working on implementing pagination in NodeJS and MongoDB. Check out the code I have written below: router.get("/PO_pagination", verify, async (req, res) => { console.log("req.query", req.query) try { let ...

What is causing the backslash character to be removed from my ajax request?

When using Ajax to call a rest endpoint, the request takes two parameters: user and permission. $.ajax({ type: 'GET', cache: false, url: "/app/Rest/4.0/UserManagement/AddPermissionToUser", data: { username: encodeURI(user ...

Add the div id to the script

Currently, I have a script set up where by clicking on a specific div (for example id=packtoa), it will add a class 'show' to listview items that have a matching class with the clicked div's id. While this system works well, I find myself n ...

problem arising from the origin preventing me from utilizing localStorage in conjunction with JSDOM

Currently, I am facing an issue while trying to load a webpage in a node environment using JSDOM. The webpage relies on localStorage for its functionality. I have attempted to load the webpage by utilizing JSDOM's URL configuration option and accessi ...

Do I need to send a CONNECT request when establishing a connection to an HTTPS URL using TcpClient/Sockets through a SOCKS proxy?

I have encountered an issue while trying to connect to www.google.com:443 via a SOCKS5 proxy over TcpClient. When the connection is proxied, my CONNECT request hangs, despite working fine with a regular HTTP proxy. Below is the code snippet causing the p ...

Adjusting the alignment of a facial image on Canvas by selecting specific click-points

I have a unique idea for an app that allows users to correct a tilted face with just 2 clicks The concept is simple - users click on the middle of the nose and the middle of the eyebrows within the image to generate two points: eyebrowMiddle(x1,y1) and no ...

Refrain JavaScript - sift through an array of objects based on the values of a primitive array in linear time

I've got an array of objects that looks like this: [{ itemType: 'bottle', itemId: '111' }, { itemType: 'bottle', itemId: '222' }, { itemType: 'bottle', ...

Ways to exclusively display map items matching those in the array

Hey everyone, I'm dealing with a map that looks like this: Map { '708335088638754946' => 38772, '712747381346795670' => 12051, '712747409108762694' => 12792 } Alongside this map, I also have an array: let arr ...

Experimenting with the static method within a singleton class using Typescript and Sinon

I have a separate layer in my application that uses a DAO class to retrieve data from the repository. I've implemented the DAO class as a Singleton and made its methods static. In another class, I've created service methods to manipulate the dat ...

After changing the value of a <select> element in Vue, the fetched data is delayed by one step

I'm currently working on a feature that involves fetching data from a URL that changes every time a user chooses a new value from a <select> dropdown. The fetched data updates the songkickData array with the latest information. However, when I c ...

What is the best way to incorporate a dropdown list into a gridview in ASP.NET for easy modification of a SQL database?

Looking to integrate a SQL database with ASP.NET for managing data related to countries. The database has three columns: id, name, and country. To display this data in a user-friendly manner, I want to use a gridview in ASP.NET with edit/delete functionali ...

In the realm of a Visual Studio solution, how is an artifact defined?

Let's tackle this straightforward inquiry. In the realm of a visual studio solution, what exactly constitutes an artifact? How do they function within the system and what are some prevailing deployment strategies? ...

Background image specifically for the Fullcalendar sun component

When setting a background image for Sunday in the month view, I noticed that the day "Sunday" in the header is also getting the same background. The CSS for the table thread has classes like .fc-sun and .fc-mon set as well, but I'm not sure how to rem ...

Which programming language is more suitable for developing a chat website - PHP or JSP?

My goal is to create a web-based chat application similar to Yahoo's, utilizing JSP/PHP with AJAX. I'm debating between using JSP or PHP for this project and looking for the advantages and disadvantages of each. Which do you think would be bette ...

Issue encountered while exporting a variable in Node.js

Issue with exporting a variable. First File const commander = require('discord.js-commando'); const ytdl = require('ytdl-core'); class exportCommand extends commander.Command { constructor(client) { super(client,{ ...

Identifying Errors in Meteor's Data Publications

I am currently working on a web application using Meteor and AngularJS 2. Take a look at the publication function below: Meteor.publish('abc', function () { // For throwing the meteor error according to the condition if(!this.userId) throw new ...

Can you help me make a JavaScript Random Number Generator that utilizes HTML input fields and buttons?

I am currently working on developing a random number generator that takes user input through HTML. The idea is to have the user enter two values and then click "submit" to receive a random number within that range. However, I seem to be stuck at this poin ...