In C# Or OOP, Should 2 Classes Reference Each Other That Are Related?

Mar 4, 2010

I am working on a class library using C#. I have designed 3 main classes to model our data. They are designed such that class A contains a list of class B instances, and class B contains a reference to a class C instance, ie:

[code]....

I feel like the class design works well for modeling the data and our business rules, but it does create a few limitations like the above situation. I liked the separation of the PolicyTerm and Billing for the ability to allow that code to be modified and tested independently. Also, I feel like it keeps each section smaller and simpler.

View 5 Replies


Similar Messages:

Display Multiple Related Classes In GridView ?

Jun 4, 2010

I would like to display students and their grades with a GridView and LinqToSQL like this:

assignment1 assignment2
Student 1 55 89
Student 2 87 56
Student 3 92 34

I have a many-to-many relationship between students and assignments called "grades". The grade for the assignment is stored in that table in a "gradeNumber" column.

I would also like to specify which assignments should be displayed in the grid. Btw, my LINQ entities are extended to allow me to write/get studentx.Assignments or assignmentx.Students.

View 1 Replies

Need Reference About Namespaces And Classes?

Mar 27, 2010

what are the namespaces that should be well known by a fresher to initiate asp.net learning, what is the main use of a namespace. what is the use of 'args'

View 4 Replies

Visual Studio :: What Is The Difference Between Designer Classes And T4 Template Generated Classes

Jan 11, 2010

I am new to LINQ. when we drag tables we get a dbml file and designer file.

For example DataClasses1.dbml and DataClasses1.designer.cs.

Once we have them then we can start using our LINQ Queries.

In my company project I do not see this designer files and instead there are .tt files which were used as templates to greate ABC.generated.cs files. Is this same as designer class?

View 3 Replies

C# - Class Structure With LINQ, Partial Classes, And Abstract Classes

May 17, 2010

I am following the Nerd Dinner tutorial as I'm learning ASP.NET MVC, and I am currently on Step 3: Building the Model. One part of this section discusses how to integrate validation and business rule logic with the model classes. All this makes perfect sense. However, in the case of this source code, the author only validates one class: Dinner.

What I am wondering is, say I have multiple classes that need validation (Dinner, Guest, etc). It doesn't seem smart to me to repeatedly write these two methods in the partial class:

[code]....

This doesn't "feel" right, but I wanted to check with SO to get opinions of individuals smarter than me on this. I also tested it out, and it seems that the partial keyword on the OnValidate method is causing problems (understandably so). This doesn't seem possible to fix (but I could very well be wrong).

View 1 Replies

C# - Can Base Classes See The Protected Fields Of Derived Classes

Aug 11, 2010

I don't know if this has to do with how FindControl works or how scope works. But my base class is having a hard time seeing the fields of child classes. Currently I'm planning have the derived class set a property in the base class, but there are a lot of derived classes, so that isn't a very attractive solution.

[code]....

View 4 Replies

Web Forms :: Using C# Classes Vb Classes Together In VS2008 / 3.5 Project

Mar 24, 2010

Can I use VB and C# classes together in the same asp.net 3.5 project?

View 3 Replies

Map Model Classes To ViewModel Classes Or Aggregate Model Classes In ViewModel Classes

Dec 15, 2010

I'm curious as to what people consider better practice, between duplicating model structure in the view model and using a mapping tool to move data between the two, or aggregate the model inside the view model, i.e. have a property on the view model class that is a reference to the actual model. Which is considered a better approach in general?

View 1 Replies

WCF / ASMX :: Call HTTPS Web Reference Through Another Web Reference - An Unhandled Exception Of Type Error?

Aug 6, 2010

I am trying to call web reference "A" in an application.

The web reference "A" will then call a function in another web reference "B" through HTTPS connection (require certificate).

Then I keep getting the following error:

An unhandled exception of type 'System.Web.Services.Protocols.SoapException' occurred in System.Web.Services.dll

View 3 Replies

Visual Studio - Why Does Website Reference Assembly From GAC, When Adding Local Reference

Jan 7, 2010

When you use ASP.NET web site (instead of web application model) and add reference to an assembly from local folder, Visual Studio, it seems, understands that this local assembly is also in GAC and so does NOT copy this assembly to bin folder (as it does with non-GAC assemblies), but simply adds new record in web.config file.

Why such a behaviour? Is it possible to force copy to bin folder (I need this since .dll is not on target environment)? I can add assembly to bin folder as file and it will work, but in this case bin folder contents will be in source control, which is not good.

View 3 Replies

MVC :: Reference To A Non-shared Member Requires An Object Reference In Code Generated?

Oct 4, 2010

I am working on converting a project from C# to VB and am facing this weird issue. 1 page cannot compile and I get the reference error, but the weird thing is that the compiler shows the error as coming from ASP.NET generated code. Visual Studio shows me that error is coming from my ASPX page. I cannot seem to figure out why or where this error is occuring. Also if I take the inherits attribute out I don't get the compilation error. The code in aspx page is below:

[Code]....

View 18 Replies

DataSource Controls :: Reference To A Non-shared Member Requires An Object Reference

Apr 22, 2010

I am using VS2005, and a newbie at table adapters, DAL & BLL. I have a single dataset (in DAL) and 2 classes (in BLL) named Class1.vb and Class2.vb.

When I try to call a function from Class1 within Class2 I get the error "Reference to a non-shared member requires an object reference".

Here is a sketch of my code structure:

[Code]....

View 3 Replies

VS2008 Update Web Reference Creates Naming Conflicts In Reference.cs?

Jan 12, 2010

I have a Web service which, when updated on one computer with VS2008 works perfectly fine, but on another computer does not. The critical difference is the contents of the auto-generated Reference.cs.

In the correctly functioning environment, the methods have fully qualified class names, refering to classes in a class library. However, in the problem environment, the class names are unqualified and partial classes are declared near the end of the file. E.g.

[code]....

The code is under source control. Checking out to the working environment works straight away, checking out to the problem environment will only work if the reference.cs is manually edited to be like the working environments. Transferring the project manually from problem environment to the working one only requires an "Update Web Reference" to be performed to allow compilation. Both Reference.cs files claim to be auto-generated by the same tool version. The settings from the good environment have been exported to the other. No success so far...

View 1 Replies

State Management :: Error Like: Object Reference Not Set To An Instance Of Reference?

Aug 25, 2010

I have a url like this:

http://www.somepage.com/main.aspx. In this page, when I click on a link it takes me to a page
http://www.somepage.com/cental.aspx?cid=200. So in the cental.aspx.cs page I did the following in the page load:

if(request.querystring["comp"].tostring() != null)
{
//do some thing [code].....

So I got an error like: object reference not set to an instance of reference.My problem is, I am using the same page. So when I go from some page, I will have "comp". but other times not. So when there is no "comp", how do I handle it in request.querystring?

View 3 Replies

Reference To A Non-shared Member Requires An Object Reference?

Oct 8, 2010

I do not receive this error when I open my website application in vs 2005. When I open in vs 2008, I get this error. What gives?

These lines are underlined in blue:

[Code]....

Businesslogic area is imported into each of 3 pages with this line.

View 9 Replies

Web Forms :: Object Reference Not Set To An Instance Of An Object Error When Remove Reference To Site Master Page

Sep 30, 2010

in my default.aspx page i have a dropdown List and a textbox with a submit button below that there are 2 listbox... and the dropdown list holds the names of the listbox

my logic here is to select an item from the dropdown list and put some text in the text box and submit the form which will add an item to the listbox selected.. but when i do this i get an error saying Object reference not set to an instance of an object. i tried to figure out the problem and found that when i remove the reference to the Site Master Page it works fine and when i undo and apply my reference back to the Site Master Page i get the same error.

[Code]....

View 2 Replies

Web Reference Versus Service Reference

Jun 9, 2010

Using VS2008, I noticed that in Class Project I only have a choice of adding "service reference" where as in Web Application project, I have two choices "web reference" and "service reference".

I have used web reference. How is "service reference" different from web ref? and what's the major purpose of service ref?

View 1 Replies

ADO.NET :: EF Saving Related Entities?

Aug 11, 2010

Having the following model Admin and AdminGroup is joined by AdminAdminGroup which has (AdminId, AdminGroupId) fields. When I add a new Admin row AdminGroups are associated with it automatically however this only works on INSERT.When I'm trying to update or associate more AdminGroup's with particualr Admin row (_repo.Update((DataLayer.Admin)row);) only Admin gets updated and no groups are ever modified.What is the correct way of updated "related" entities? so that AdminGroup also get's updated.

View 6 Replies

ADO.NET :: Related Rows Are Not Loaded?

Nov 21, 2010

I want to have two combo boxes: One for categories and one for subcategories. As a category is selected in one combo box, all the related subcategories are displayed in the other combo box. EF 4.0 should be perfect for this. But the subcategory collections are always empty!

[Code]....

I can see that Lazy loading is set to true. I tried setting it to false and adding Include("Subcategories") but the subcategories collection is always empty.

I even tried using the SQL Server Profiler. Although I couldn't explain the timing, I could in some cases see the queries to return the subcategories. I even executed the query and it returned the expected results.

I'm really getting frustrated by EF. Although I'm fairly new to SQL Server, I could've had what I'm working on done hours ago. Instead, it's like a black box with no way for me to troubleshoot or determine what the heck is going wrong.

View 8 Replies

ADO.NET :: Display Value From Related Table?

Jan 18, 2011

I have 2 tables:

User(Id PK, TitleId FK, Name, Active)

Title(Id PK, Text)

Title is a lookup table of titles (Mr, Miss,...) and its got a relationship with table User by TitleId.

Now I'm trying to display the data in a web page using .net and Entity Framework. I'm using a ListView control and a query as a source. it all displays fine except for the Title.

Here is my code:

MyEntities _entities = new MyEntities (); User user = new User(_entities); IQueryable u = (from x in _entities.Users where x.Active == true select x); ListView1.DataSource = u; ListView1.DataBind();

and the code in the front end:

<asp:ListView ID="ListView1" runat="server" EnableModelValidation="True" DataKeyNames="Id"><ItemTemplate> <tr> <td> <%# Eval("Id") %> </td> <td> <%# Eval("Title.Text") %> </td> <td> <%# Eval("Name") %> </td> </tr></ItemTemplate><LayoutTemplate> <table ID="itemPlaceholderContainer" runat="server"> <tr runat="server"> <th id="Th2" runat="server"> Id</th> <th id="Th1" runat="server"> Title</th> <th id="Th3" runat="server"> Name</th> <th runat="server"> </tr> <tr runat="server" ID="itemPlaceholder"> </tr> </table></LayoutTemplate>

How do I manage to get the Title Text associated with a User to display on the ListView?

View 4 Replies

Using A Grid That Isn't Related To A Datasource?

Jun 10, 2010

What i want to do is have a grid i can add rows and columns and cells. each cell i want to have an image button in. I want to do this in a windows form. Is this posible? I was looking into the gridview/datagridview but that wasn't what i wanted.

View 1 Replies

Looking For Ecommerce Related Video Tutorial

Sep 3, 2010

im looking for ecommerce development video tutorial. I already watched related video tutorials on ASP.net website.

View 2 Replies

SQL Server :: How To Use Query To Get Related Data

Jan 3, 2011

I have a table articles where i keep all the records of the articles wriiten by people online. Now i need to retrieve related articles based on the title i guess. I tried doing that using my stored procedures with the LIKE operator, but i guess that doesn't work because it does not take the whole string of the title and match with the ones in the database.

View 2 Replies

ADO.NET :: How To Join 3 Related Tables With Linq To Sql

Nov 9, 2010

Here's my DB structure:

I have three tables.

User, Details, Optional
User has fields: ID, FirstName, LastName
Details has fields: ID, MyDetails1, MyDetails2, User_ID
Optional has fields: ID, MyOptions1, MyOptions2, User_ID
There is a 1 to many relationship with User & Detail (User ID & Detail User_ID)
There is a 1 to many relationship with User & Optional (User ID & Optional User_ID)

With that said, one user can have many details and/or many optionals

Now I'm trying to build a linq query that will say:

"where user id = x, select FirstName, LastName, all MyDetails1 from every record where User_ID == x, all MyOptions1 from every record where User_ID == x"

After the merge I should have one string that lists the distict user & all of their many fields:

FirstName + LastName + (MyDetails1 + MyDetails1 + MyDetails1..etc) + (MyOptions1 + MyOptions1)

Anyone try this before?

I tried this with JOIN but this doesn't do the trick for what I'm looking for.

So if I had 3 MyDetails records associated with ID == 2, I would get three results like:

John Doe MyDetails_X
John Doe MyDetails_Y
John Doe MyDetails_Z

View 1 Replies

How To Get Related / Similar Search Results

May 20, 2010

What's the best way in ASP.NET MVC to get a few questions related to the current question (like on stackoverflow) without using tags?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved