.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Imran Ghani
Post New Web Links

Data Class Best Practices Question

Posted By:      Posted Date: October 24, 2010    Points: 0   Category :ASP.Net
 

Hi all.

I have a class called employee.  I have several private fields (i.e. mHiredDate, mSickDays, mVacationDays, etc.).  I instantiate employee objects thru out my website application.  When I make a change to the private fields using the public property set method, is it a better practice to make the changes thru out the session and save the values back to the database near the end of the session or make the set make the change to the database everytime it is called?  Does the same go for get ?  Do I have my get goto the database and grab the value everytime I need it ?

I hope my question is clear enough. 

Thanks Smile

 




View Complete Post


More Related Resource Links

EF Data Access: EF v2 and Data Access Architecture Best Practices

  

Developers deploy a wide variety of development philosophies and architecture styles. This article explores three common perspectives on application development and describes how the Entity Framework can be employed in each. Specifically, the article looks at the forms-centric, model-centric, and code-centric development styles and their relationship to the Entity Framework.

Tim Mallalieu

MSDN Magazine August 2009


Zip Your Data: Using the Zip Classes in the J# Class Libraries to Compress Files and Data with C#

  

Zip compression lets you save space and network bandwidth when storing files or sending them over the wire. In addition, you don't lose the directory structure of folders you Zip, which makes it a pretty useful compression scheme. The C# language doesn't have any classes that let you manipulate Zip files, but since .NET-targeted languages can share class implementations, and J# exposes classes in the java.util.zip namespace, you can get to those classes in your C# code. This article explains how to use the Microsoft J# class libraries to create an application in C# that compresses and decompresses Zip files. It also shows other unique parts of the J# runtime you can use from any .NET-compliant language to save some coding.

Ianier Munoz

MSDN Magazine June 2003


Building a Custom Data Grid: Performing Ad Hoc Web Reporting with a VBScript 5.0 Class Object

  

A flexible, customizable grid for displaying data is a useful tool for ASP developers. It allows Web visitors to customize their view of your data. This article takes the data grid presented in "Ad Hoc Web Reporting with ADO 2.0" by John Papa and Charles Caison (MIND, December 1998) and adds handy features such as a finds feature that supports multiple finds and a mode for adding and editing records. This version also improves response time by allowing asynchronous record download and it componentizes the code so it can be used as a standalone VBScript class object that can be reused in other pages.

Randall Kindig

MSDN Magazine July 2000


send data in class object from one page to another using session

  

hello everybody

now i hav stored all data like user name, data fatched from database of that user

and i stored that data and user name such as:

string strUserName="user name"

dataset ds =new dataset();// data of that user

now i wan yo send d whole data from my login page to user profile page

can anybody help me for that...................

and plz tell me that how much is this way is benifitial to send data from one page to another page

plz........kindly waiting for positive rply


A simple Data Modeling Question

  

I have a data modeling question that hopefully this fictious example will help explain.  My application is data driven and the classes reflect the tables to a large degree.   In this example my database has two tables:

  • VendorMaster with an int Primary Key of VendorID
  • VendorContact with an int Primary Key of ContactID

The VendorContact table also has a Foreign Key of VendorID in order to associate the contact with a specific Vendor.  In this example a Vendor can only have one contact.

My question is how to represent these two tables in terms of classes.  In my current design I have two classes:

  • VendorMaster
  • VendorContact

In order to represent the relationship between a VendorMaster and VendorContact, my VendorMaster class contains a property called VendorContact.

My questions are about the VendorContact class and how it represents the relationship between a VendorMaster and itself.

Option #1

The VendorContact class should contain an int property of VendorID

Option #2

The VendorContact class should contain a VendorMaster Property

I am not sure which option is the 'best' option to take. My concern is that if I go with option #2 that I would create a cyclical relationship between the VendorMaster and Vendo

The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database

  

Hello everybody,

 

i am encountering an exception in my in my application at these lines of code.

 

DatabaseProviderFactory dbFactory =

new DatabaseProviderFactory(dataSource);// Create and return a database object.

 

return dbFactory.Create(name);

 

i am getting this exception at the create line

 

The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database, 125ba2c1-9573-45be-b8a2-b370deff980d]) failed: Exception has been thrown by the target of an invocation. (Strategy type ConfiguredObjectStrategy, index 2)

 

I have referenced the proper assemblies in my project and on  other systems, its working fine.

The connection string is DB2.My db2 connection is also good with no issues. My stack Trace

All data in class properties disappear across WCF service

  
Hi, I have a class that i share betwee silverlight client and wcf service. I populate properties of the class with real data from the client, to be used in the server. I use debugger to step through the code when the call gets to the server, all the data ara gone and are replaced with null. All DateTime value change to 1/1/1001. But if pass primitive types such as int, string, no problem. This is happening only on one machine, but not on ther machine. Can someone tell me what is going on here? Thanks in advance

Simple data binding question

  
Newbie binding question here: is it possible to bind a control in XAML to a StaticResource by passing in the key via a data structure? Basically something like this: <TextBlock Text="{Binding ImageKey}" /> <Image Source="{StaticResource ResourceKey={Binding ImageKey}}" /> <-- doesn't work   The TextBlock binding on the first line works correctly, it extracts the key of the StaticResource from my data structure and displays it correctly. What I'm trying to do is get the Image control to bind to the StaticResource with that name (which happens to be a BitmapImage).      

Storing multiple data types in a class?

  
I need help writing a class that will contain three values per item.  I'll be passing parameters to a report: Parameter Name, Data type (int, string, date, etc), and Value. When I pass those values to the report using the class they should be in original form (i.e. an integer should be a numeric, a string should be a string, etc.).  I can do it converting the data's value to strings on one end, and reconverting to the original data type on the other, which seems like a lot of runaround. Is there a simple way?  Also, if I'm able to store & retrieve the data in it's native format I don't need the "Data type" stored. Any help or tips will be appreciated.

Data Mining Solution Question

  
Hi, I am working for a company that would like to use Aanalysis Services for predictive analytics. My problem is that there are only 40 or so months worth of data. I am wondering if this is enough to even make anything relevant and/or accurate.   So far I've made a time series mining structure, that just uses the booking number as input and predict. I am having a hard time justifying this as they view it as something that could have just been done in excel.   Also I have made a neural network. The company has several (continuous) metrics that they track along with bookings. So I made a neural network to use these inputs to predict the bookings.   This made another problem. The prediction that the neural network makes is different from the next month that that time series predicts and is causing distrust by the potential end users.   I've thought about combining the two models. I could use the output of the neural net and do a natural prediction join of that result into the time series.   Seeking advice, and something that I can do with Analysis Services that could be useful to a company with only a small number of months of data to work with.   -S

SQL server 2008 r2 Data sync question???

  
Sql 2008 r2 data sync, does it involve a db hosted by microsoft or does that involve us hosting the sync functionality locally?  I know we have db's local that need to be sync'd across a wan but does that happen in a db hosted in the ms cloud or does that have to do with a sync functionality that runs locally to keep my db's sync'd?   Thanks, SL

Data Mining Solution Question

  
Hi, I am working for a company that would like to use Aanalysis Services for predictive analytics. My problem is that there are only 40 or so months worth of data. I am wondering if this is enough to even make anything relevant and/or accurate.   So far I've made a time series mining structure, that just uses the booking number as input and predict. I am having a hard time justifying this as they view it as something that could have just been done in excel.   Also I have made a neural network. The company has several (continuous) metrics that they track along with bookings. So I made a neural network to use these inputs to predict the bookings.   This made another problem. The prediction that the neural network makes is different from the next month that that time series predicts and is causing distrust by the potential end users.   I've thought about combining the two models. I could use the output of the neural net and do a natural prediction join of that result into the time series.   Seeking advice, and something that I can do with Analysis Services that could be useful to a company with only a small number of months of data to work with.   -S

Question about quality of data

  
Hello, Thanks for the help on the last question.  We have looked at several open source offers in the field of data integration. We are now wanting data quality software to complete our data integration program.  Do packages exist to suit our needs? Would you know of innovative data quality programs? Thanks to all!

ASP.NET and Entity Data Framework - Best Practices?

  
Hi I'm looking for some advice regarding using EDF and ASP.NET. My main concern is the use of contexts within my code. What is the best way to handle contexts?  Currently I'm getting the dreaded error: "An entity object cannot be referenced by multiple instances of IEntityChangeTracker."  What's the best way to ensure I'm using the same context? What are the implications for leaving a context 'open' in the Session? Is this a big 'no no' ? How can I achieve a consistent approach (without having to pass context parameters all over the place) and yet keep my application scalable? Thanks, Simon.

Calling a method with a class object as parameter data type.

  
   [WebMethod]    public string GetInfo(Customer inCust)    {        // Code in here    } I have a web service that resides on a remote server. I want to call a public method of theweb service named  "GetInfo". The method is shown above. The web service method expects a class object oftype "Customer". What I did to create a Customer object was to define in my asp.net project my own class named "Customer" which is exactlythe same as the class that belongs to the web service project on the remote server. I then created an instance of Customerand tried to call the web service passing in an object of type customer : my.Service ws = new my.Service(); // Get web service connectionCustomer aCustomer = new Customer();aCustomer.Initialize();ws.GetInfo(aCustomer) // call web service passing in a Customer object The problem is that the compiler gives me the following error: Value of type '_Default.Customer' cannot be converted to 'ws.Class1'. Here Default is refering to my Default.aspx.cs code. Why is this? Do I need to Cast my "aCustomer" class object to a type ofws.Customer ? How do I do that?

Can I use class members for data or do I need to use Variable?

  
I have a class derived from CodeActivity that creates some objects in its constructor which will be used by Execute. These objects are exposed as properties so I can fake them for unit tests. In a code review a colleague suggested that I might need to make all of those objects Variable<T> "for them to play nicely in WF (with all the threading etc. going on)", but wasn't sure on that. Do I need to make these Variable<T>? If not, when would I want to use Variable<T> in a CodeActivity?

Another basic Data Binding question

  
3 days ago (thanks to Olaf) I was able to make progress with binding a data collection to a DataGrid. Since then I have searched the web in vain for a VB example to enable me to switch off the DataGrid AutoGenerateColumns and enter my own columns and appropriate Paths to the Collection’s properties.   The following code works fine but I can’t work out how to enter my own individual columns etc. Can anyone give me the syntax for an example of one column please?   Why is it so difficult to find VB examples of WPF demos etc? (Nearly everything is in C#.)   I have some experience in Access VB so have picked VB in trying to use WPF. I would be grateful for any links to VB WPF resources. Option Explicit On Option Strict On Imports System.Collections.ObjectModel Partial Public Class DataGrid_FilledFromCodeBehind Private _ocEng As ObservableCollection(Of EnPlayer) Public Property EngSqd() As ObservableCollection(Of EnPlayer) Get Return _ocEng End Get Set(ByVal value As ObservableCollection(Of EnPlayer)) _ocEng = value End Set End Property Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded _ocEng = New ObservableCollection(Of EnPlayer)() For i = 0 To 4 EngSqd.Add(New EnPlayer(ref(i), names(i), ages(i), bat(i))) Next Me.DataCon
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend