Asp.net Mvc - .NET - Efficient Collection Of Database Entities?
Jan 15, 2010
I have a Page class and a PageCollection class in a 3d party ORM framework. I can fill the PageCollection based on parameters (pageid, parentid, url etc..) (SQL query). But I need the data multiple times around the ASP.NET MVC website (Sitemap, Authentication), so I chose to load all pages 1 time and reference that (global) collection.
GlobalClass.Pages //is PageCollection containing all pages
I have now created functions which return a temporary subcollection or single entity based on the parameters mentioned before (pageid, parentid, url etc..).
GlobalClass.Pages.GetByPageId(id) //returns single page entity
GlobalClass.Pages.GetByParentId(parentid) //returns subcollection
The site however got very slow.
cache the subcollections (GetByParent())? create internal hash-lookup tables for the collection? Something else...?
Namespace BLL
Public Class PageCollection
Inherits CustomCollectionBase
[Code]....
View 1 Replies
ADVERTISEMENT
Apr 24, 2012
The documentation has an example about grouping on multiple properties[code]...
Is it possible to rewrite the original query to just return IEnumerable(Of CustomerRegionGroup), or do I have to use the anonymous type, and run a second query on the result of the first?
View 1 Replies
Nov 9, 2011
I am looping through my dataset to save my database, I thought this might not be the best way. Is there a more resource efficient of doing it?
For i As Integer = 0 To CO.Tables("CO_Del").Rows.Count - 1 'CO is my DataSet
dbCommand.Parameters.Clear()
AddInParameter(dbCommand, "@IsDelete", DbType.Boolean, 0, DBNull.Value)[code].......
View 3 Replies
Jan 8, 2011
I was wondering what was the best way to search a database. Is it possible to perform bubble sort etc or any sort of binary search to the database instead of doing a linear search. If so how would I go about doing this through an Sql statement.
View 6 Replies
Mar 6, 2009
Whats the best way to handle the connection to a db when it's accessed often? I have an app where the user selects an item from a drop down list(call to the db) and then a picture of the item is returned along with it's relevant information(another call to the db). Small application but basically every action results in a call to the database. Should i just be filling like a global dataset and then accessing the information from there(if thats possible)? The database is stored locally(currently an Access Db but will be SQL in the future)
View 3 Replies
Sep 17, 2011
I've just gotten started with development using Visual Studio (though this can be seen as a more language-generic question), and need done design answers regarding how to suitable relate a Database Entity/Table with an Class in-code.
Currently, I create a class who's attributes or iVars directly correspond to the fields in an Entity.
When I come to fetching all 'Customers from a Table' for example, I run a Select all statement against the database and for each result-row returned, I instantiate a new class Object where I use the Class' default constructor to set the instance variables. (I really wish there was a method like PHP's mysql-fetch-object()?)
I can then add each of these objects to say, a List(of Customer) and return it.
This doesn't seem like the best way to do it. If I were to change the Database schema, I'd have to reflect those changes in the class also.
View 1 Replies
Jan 9, 2012
i am caching objects, if i make linq queries on cached entities then... will theses queries make database round trip due to lazy loading in Entity framework?
View 1 Replies
Jun 22, 2010
making a log in form for administrator using the accounts from the MySql database .. i want to know the code in connecting database, because i am new in SQl database Programming.. xample there are 2 fields in SQL database the Username and Password.. the elements inside the field Username is admin and in Password is asusTek. how can i trigger the user if he enter in the wrong Username and Password in two textbox in the form .... I am Using Visual Studio 2005 and my SQL is SQLExpress Edition with SQL server 2005
View 1 Replies
Mar 4, 2011
How would I create a function to return one database row in a collection, such that the rows column name & value are stored as key/value pairs in the collection?
View 5 Replies
Apr 26, 2010
I am populating a collection from some tables in the database which serves as a look-up from controls (combobox) I am using but what I want is rather than hitting the database each time can I just cache the collection and get the collection from the cache? The look-up table may or may not change all the time so I would want to have a way to validate if the cached collection is still valid or not.
View 2 Replies
Feb 1, 2012
I will be doing an MVVM Project soon and I'm working a couple tutorial/examples out. How do I take the following code and connect it to a database. If I were to have a datagrid, how can I change information in the datagrid and have it automatically update? I'll be using MS SQL.
[Code]...
View 1 Replies
Oct 24, 2010
I would like to populat the Listbox collection from a column from a Access database I already created the name of the collection as collections. I can autocomplete/Suggest a Textbox with no issues.[code]
View 2 Replies
May 12, 2011
I would like to be able to save to a db and send task to email or as text msg for instance nevermind that.. I have two variables of type ArrayList they are "_mList1" , "_mList2" and "_mList3"
_mList1 stores the list of Telephonenumbers , _mList2 stores the list of StaffIDs and _mList3 Some concatenated string.
theses variable lists will hold some data in runtime as explained and i would like to use them to populate a DB table again mentioned
tblTask (TaskID(PK), Action, StaffID(FK), AssignedBy, TelephoneContacted, NotesCotent)
tblStaff (StaffID(PK), FirstName, Surname, Telephone, Address etc..)
[Code]....
View 1 Replies
Apr 17, 2010
I am populating a datagridview not with a datatable but with a list of instances of a class I created. The data for the instances is read from a database.
Looks like this:
Public Function GetSecurities() As System.Collections.Generic.List(Of Security)
Dim com As New SqlCommand
Dim rdr As SqlDataReader
[Code]....
View 13 Replies
Nov 4, 2010
It seems that when using With blocks in VB.NET, the resulting MSIL larger than w/o. So this leads me to ask, are With Blocks really more efficient? MSIL is what gets JITed into native machine code, so smaller code size should imply more efficient code, right?
[Code]...
View 5 Replies
May 4, 2010
Where to add this validation, or if there is a more efficient way of doing it and where to put it?
CODE:
View 6 Replies
Aug 9, 2009
How to use MVC Pattern efficient?
View 8 Replies
Jul 26, 2011
Is there a more efficient way of doing this code?
For Each row As DataRow In dt.Rows
Dim ts1 As String = row(0).ToString
For index As Integer = 1 To 9[code]....
View 2 Replies
Aug 26, 2011
just wondering which of these two sort methods would be more efficient movies.OrderBy(Function(m As Movie) m.Title)
[Code]...
View 1 Replies
Apr 14, 2009
Visual studio 2005 - vb.net..I have a user control on a form containing 15 combo boxes.All contain Y, N, and blank (for Yes, No, or blank) in the Items Collection property.Each of the combo boxes have a binding source to the same table, different fields.When you select a value Y, N, or blank for any of the fields and do a save, the values save while the application is open.Once you close and reopen, the values are gone.It appears the dataset does not recognize the change, so the values are not getting stored in the database table. Is there something I can do or put in one of the events that would identify this as a change.
View 3 Replies
Nov 4, 2011
The tables described herein both utilize composite keys. I have a parent table that stores eligibility information per "case". The child table stores eligibility information regarding each individual associated with the case. The child records are differentiated by pin number to make them unique in the child table only.
I am using NHibernate v3.1 with Fluent NHibernate v1.2, both acquired via NuGet packages. The entities are mapped in using the Fluent NHibernate auto-mapper functionality. Any custom mapping is done in the mapping override method for each entity.
Another thing to know is that these tables do not have a "primary key" defined in DB2. They only have "unique keys", which are what you see in the composite key definition below (see code).
T0026_AG_ELIG is the name of the parent table and the corresponding POCO class.
T0265_AG_IN_ELIG is the name of the child table and the corresponding POCO class.
Problem:
The problem is that when I execute the query, all the data is queried, the parent record is successfully mapped to the class, but the returned child rows do not map into the collection on the parent class. NHibernate does generate the queries for the parent and child data. When I execute my own query against the database, the correct data for the conditions does come back. For some reason, the child records are just not being bound to the property on the parent (T0026) class.
Question:
What do I need to do to get the multiple rows coming back from T0265_AG_IN_ELIG to map to their corresponding class and load properly into the specified collection property on the parent class (T0026_AG_ELIG)?
Collection Property of Parent (T0026_AG_ELIG):
Public Overridable Property IndividualEligibilityRecords As IList(Of T0265_AG_IN_ELIG)
Mapping Override for Parent (T0026_AG_ELIG):
mapping.CompositeId() _
[Code].....
View 2 Replies
Oct 21, 2011
So in my program I have a database where I send info such as passwords, is there any way to (in an easy way) encrypt the password before sending it so instead of sending "mypassword" to the database I send a random collection of letters and numbers like "shH3n2ja"? I only need two functions, encryptPassword, decryptPassword.
View 7 Replies
Jan 15, 2010
Is it good practice to store sub-collections of item X inside a parent collection of item X for caching 'filter-queries' which are performed on the parent collection? (They won't be used together (as in color AND type).) Or is it also ok to just Loop over the collection and return the correct entities in a temporary collection?
[Code]...
View 1 Replies
Sep 7, 2011
I have the following classes:
Product, Service and OrderItem
Product and Service must inherit OrderItem. So basically I want to store OrderItem object in my shopping cart and these object are store in a list.
Public MustInherit Class OrderItem
Private m_enuItemType As TypeOfItem = TypeOfItem.None
Private m_strUserID As Integer[code].....
View 1 Replies
Jan 5, 2010
I need to verify if a certain user exist on my asp.net site.I want to know if which of these two functions is more efficient, faster and better compared to each other and why.
[Code]...
View 6 Replies
Aug 1, 2009
I am working on an application that will need to read tons of records (close to 500,000) from one table and insert them into another set of tables in the same database. I though about using SSIS package for this but our DBAs don't want to use that. Now, I am thinking of a multi-threaded approach. I am thinking that I can have a few thread started that will read say (500) records at a time and insert them, then come back and read more.
Now, say I spawn off 3 threads of this application. The first thread reads 500 rows and starts processing them. Can I lock these rows that were already read so that the next thread does not pick them up? I am trying to find some articles regarding this on the internet, but perhaps I am not searching for the correct terms in Google.
View 6 Replies
Jul 1, 2010
I'd like to sample the data from the Arduino @ roughly 200Hz. Is there a more efficient way to do this than using a timer (which is what I am currently using)? Currently I am using[code]....
View 3 Replies
Nov 7, 2009
if there is no need for my variable to store negative values, is it more efficient to use UInteger instead of Integer? both are 4bytes and i've got a feeling unsigned works faster though i'm nt sure about it. note that the range of my variable is 0 to 2147483647, hence i could use a UInt32 or Int32 and both would give me the same result so i'm wondering about optimum performance.
View 7 Replies
Jun 22, 2010
I have been reading books trying to learn .net on my own. I am working on an exercise that asks me to create a 1MB file. what i have below does work, but it seems to me there would be a more efficeient way. It seems like what i am doing would cause a lot of overhead. making a 1MB file easier than what i have?[code]...
View 2 Replies
Jul 28, 2009
I have a program that must initialize a table that is usually about 10-15 thousand records. I have attempted several means to empty the records from it, but it always takes several minutes to accomplish the task or in some cases like a 'bindingsource.clear' command, doesn't work at all. I currently have it working using a simple loop to go through each record at a time and 'removecurrent'. but this seems extremely inefficient and it is quite slow.The real time consumer seems to come in with the tableadapter.update and tableadapter.fill that happens after the loop.[code]
View 6 Replies