Inheritance And Entity Classes In VB 2008?

Jun 27, 2011

I am having trouble getting inheritance to work with the VB 2008 Express entity classes. I am a beginner with VB.Net and self-taught in VB6.0.I am able to pull data from an SQL Server data base into my application using the O/R designer. The data can be successfully queried using LINQ to SQL, either returning a single record, or multiple records or an entire table as a collection of the enty class type (so the problem is not with LINQ queries).

View 2 Replies


ADVERTISEMENT

Inheritance In Classes And Extending Subs ?

Feb 26, 2011

I've been wondering if there is anyway to extend a sub of a base class in a derived class or subclass. To date, the only thing I've been able to find is overrides and overloads functions, but to my understanding these functions just ignore your base class's sub and just allows you to run the new one with the same name.

What I want to be able to do is:

CODE:

I'm not sure whether this is possible, or if I'd simply either make a new sub in my derived class that first ran the base's class sub or whether I'd override the base class and then copy and paste the old code.

View 6 Replies

Creating Entity Classes With The O/R Designer?

Aug 15, 2011

I am using the O/R Designer to create entity classes in VB 2010. I am observing different results for different database tables that I can't explain and more importantly, can't replicate the results that I want.Using server explorer, I have dragged a number of tables on the O/R designer surface, thereby creating the entity classes.

I have saved the project and can access the various entity classes in my project code. I first noticed a difference when changes made to object instances from some tables/entity classes appeared to persist while changes made to object instances from other tables/entity classes did not persist. These object instances are created, accessed, and changed using the exact same code patterns except for the object, class and table names.

I have been looking to see if there are any differences between the way in which the entity classes are treated, either in my code, in server explorer, or in the O/R Designer. I cannot find any. The properties of the entity classes indicate that all of the classes use the runtime methods for insert, delete and update. As far as I am aware, I have not knowingly made changes to these methods.

The ONLY difference that I find is in the file NameofClass.designer.vb. This is an automatically generated document. The partial class of those objects that appear to persist changes contains different code from that of other partial classes where changes to objects do not persist.In the declarations section of this partial class, the following lines appear:

<Global.System.Data.Linq.Mapping.TableAttribute(Name:="dbo.OrderofBattle")> _
Partial Public Class OrderofBattle
Implements System.ComponentModel.INotifyPropertyChanging, System.ComponentModel.INotifyPropertyChanged

[code]....

If I am right then I want to enable persistence in my other classes by causing this additional code to be generated for them. But how? why the code for this one class hase been generated differently than for all the others (actually it is this way for 2 out of about 15 classes). What setting or or selection do I have to make to enable this code to be created for my other entity classes during the automated process?

View 3 Replies

Design Patterns - Inheritance - Do All Properties In The Derived Classes Have To Be Declared In The Base Class

Aug 8, 2011

Background:I have a base class and several inherited derived classes. The derived classes don't always need to have the same properties. If any properties are shared among the derived classes, those properties would live at the base class level ('Contents', for example).Similarly, GoodDocument below has 'GoodThings' but would not want/need to have 'BadThings'.I want to treat instances of both 'GoodDocument' and 'BadDocument' as type 'Document'

public mustinherit class Document
public property Contents as string
public sub new()...

[code]....

View 3 Replies

Inheritance (Private Overrides Function) - Create A Class And All Other Classes Inherit From It And Modify It A Bit

Oct 15, 2011

I am cleaning up some code and I have multiple classes that are 99% exactly the same. So my understanding is that my options are...

1. Create a class and all other classes inherit from it and modify it a bit

2. Create an abstract class and all classes inherit from it and modify a bit ** I took this route

3. Create an interface and all classes Implement that interface.

Here is my 'original' class below (the one that all of them look 99% identical). This class is used in an arraylist so I have a listing of all my images from a folder I have searched.

[Code]...

View 10 Replies

Using Inheritance-Based Controls - Creating As New Classes (not UserControls) Inheriting From An Existing System Control

Oct 15, 2011

I seem to be having a problem with controls that I am creating as new classes (not UserControls) inheriting from an existing system control. Everything seems ok while I create the control code, through to the compile (which is successful and adds the control to the toolbox) and dragging the control from the toolbox to the GUI surface. However, when I then debug or compile the project, I get a message such

[Code]...

View 2 Replies

Best Pratice In Inheritance - Three Classes Employee, Manager And Salesman. Manager And Salesman Classes Inherits Employee Class

Jul 27, 2010

I have three classes Employee, Manager and Salesman. Manager and Salesman classes inherits Employee class.

Employee :

Public MustInherit Class Employee
' Field data.
Protected empName As String
Protected empID As Integer
Protected currPay As Single

[CODE]...

Manager :

Public Class Manager
Inherits Employee

[CODE]...

Salesman :

Public Class Salesman
Inherits Employee

[CODE]...

Now I have created a object of salesman and manager using the following code:

Dim objSalesMan as Employee=new Salesman("xyz",1,2000,5000)
Dim objManager as Employee=new Manager("abx",2,5000,"production")

Is this a good programming pratice or should I use:

Dim objSalesMan as new Salesman("xyz",1,2000,5000)
Dim objManager as new Manager("abx",2,5000,"production")

View 6 Replies

DB/Reporting :: Wrap Entity Framework-generated Classes?

Nov 19, 2008

I'm using a 3rd party tool to generate my model including code classes for the MS Entity framework. What I wanna do is etablish a real layer application. I'm speaking of the layers:

Presentation
Business
Data

If I'm not wrong the generated classes represent the data layer. My question is if I should wrap this classes up for my business layer or not. In some way these generated classes already represents the logic of my application as it was derived from my database. But is this enough?

I definitely wanna use LINQ as well which works pretty good with the generated classes alone.

I'm looking forward to any comments.BTW: It's going to be a ASP.NET web application. I have used the projetc type "class library" for the data layer. The web application will use this DLL.

View 1 Replies

Asp.net - Linq Group By An Entity And Then Order By The Grouped (nullable) Entity

Jul 27, 2011

I am trying to build a survey engine from an existing database design which is like this.

[Code]...

The line Order By Key.RecordOrder throws a null reference exception and I can understand why. Can someone advise on how to resolve this by just modifying this one query? I am fairly new to LINQ and the necessity to write this project

[Code]...

View 1 Replies

.net - ADO.net Entity Framework - Update Only Certain Properties On A Detached Entity

Jul 22, 2009

I want to update an entity without loading the entity from the database first. I've accomplished this but only by knowing all of the entities properties and then using the "attachto" method. My issues is i don't want my app to need to remember all of the properties. Example:

[Code]....

View 3 Replies

.NET Sample Entity Framework 4.2 Code First Entity Splitting?

Dec 14, 2011

Entity Splitting: one class, two or more tables.Here is how it is done in C#, but I need to get it working in vb.net.One more thing: the class name and table columns do not match, so I have to be able to map that out, too.I have to get this to work this way because the place I'm working at right now is a vb.net only shop and the database schema is fubar, but they have so much (millions) of lines of code done directly against the database in both asp classic, vb.net, AND asp.net webforms that changing the schema right now is not realistically possible.

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Post>()
.Map(m =>

[code]....

View 1 Replies

VS 2008 Inheritance And Events

Jul 8, 2009

I have a base object, with a event that can be triggered by multiple methods.Then I created a child object that inherits that base object. I want to be able to trigger that event in the new object; but I can't use RaiseEvent to raise a base-object's event.To get around this, I created a small method in the base object that takes the argument for the event and I just use it to trigger the event. Is this the proper way to handle this situation? Similarly, I could Shadow the event with a duplicate one in the child object.Is there a standard way to handle events across inheritance?

View 2 Replies

VS 2008 Inheritance Question (or Maybe Not)?

Dec 15, 2009

I've not played with inheritance myself much as I've never really had a need to, but now I have a situation which to me seems the ideal time to learn. I'll explain:

This is a WPF application but that shouldnt make any difference to this question. Basically, I have asearch window that retrieves data from a database - I want this one search window to be able to retrieve any item (business object might be a better word than item) from the database and display the relevant data, rather than having a separate window for each 'type' of item in my program. So I have got 3 classes at the moment, ComputerAudit, ConnectionAudit, and SoftwareAudit and I want my one search window to be able to display any of these items in the listbox. Obviously there would only be one type of item displayed at once, so there wouldnt be a computeraudit item and a connectionaudit item displayed in the list at the same time, but there could be several computeraudit items displayed.

So I thought I could create a base class just named Audit and have those 3 classes I mentioned inherit from that, then I can specify the arguments to methods I am using as just being of type Audit (rather than using a specific type like ComputerAudit or SoftwareAudit) because then I should be able to pass around any of these items which inherit from Audit right? Well that doesnt seem to be the case so I'm wondering if I have misunderstood inheritance.

The problem I'm having specifically is that I have some methods which need to be able to accept any of my Audit subclasses but if I specify a generic List(Of Audit) then it wont let me pass in a List(Of ComputerAudit) for example. Is this because I'm using a List or am I just doing something fundamentally wrong?

EDIT: Found this page which confirms my suspicions that this is more to do with the List than general inheritance:[URL]...

View 39 Replies

Asp.net - Using ExecuteQuery() With Entity Framework, Entity Class

Jan 16, 2011

I am trying to jump from ASP Classic to asp.net. I have followed tutorials to get Entity Framework and LINQ to connect to my test database, but I am having difficulties figuring out ExecuteQuery(). I believe the problem is that I need an "entity class" for my database, but I can't figure out how to do it. Here is my simple code:

Dim db as New TestModel.TestEntity
Dim results AS IEnumerable(OF ???) = db.ExecuteQuery(Of ???)("Select * from Table1")

From the microsoft example site, they use an entity class called Customers, but I don't understand what that means.

View 1 Replies

C# - Inherited Entity Item Not Recognized As Entity?

Feb 11, 2011

I am trying to create a generic typed class, but am running into a problem. Here is my basic class definition:

public class QueueObject<T> where T : System.ServiceModel.DomainServices.Client.Entity
{
public string LoadingMessage { get; set; }
public System.ServiceModel.DomainServices.Client.EntityQuery<T> Query { get; set; }
}

I am trying to add instances of this class to a queue

private Queue<QueueObject<Entity>> _queue;
this._queue.Enqueue(new QueueObject<MyEntity> {Query = MyContext.GetMyEntitiesQuery(), LoadingMessage = "Loading some stuff"});

This doesn't work. I get an error saying that QueueObject cannont be converted to QueueObject. I don't understand because MyEntity inherits from Entity.

Public Class QueueObject(Of T As System.ServiceModel.DomainServices.Client.Entity)
Public Property LoadingMessage As String
Public Property Query As System.ServiceModel.DomainServices.Client.EntityQuery(Of T)
End Class

[code]....

View 2 Replies

VS 2008 Object Inheritance And Casting

Mar 23, 2011

I have two custom objects.On of them inherits the other one, appends few more properties and methods, ovverides some other.When I try to cast the Parnet Object to Child I receive an error that it could`nt be done.

View 1 Replies

VS 2008 : Inheritance And Copy/use Of Member Instances?

Jul 31, 2010

If I declare and instantiate an instance of class B within class A, how do I make instances of class A member objects/variables accessible from class B?

View 11 Replies

VS 2008 DGV Inheritance - Create The Control In Another Project To Build The Dll

Nov 26, 2009

In my application i will use a customized datagridview for all the application, so instead of adding the normal datagridview and changing the properties, i created an user control and changed the inherited to datagridview... This have a problem i can't use the drag and drop...

[Code]...

View 4 Replies

[2008] System.Data.Entity GAC Error?

Mar 5, 2009

VB EXPRESS 2008. I am getting random Users that are receiving this error during install? for some, if they reboot, it works...for others no good.

I have looked and tried all sorts of things.. made people go to net 3.5 sp1, removed the add desktop shortcut, removed all unused refs.. etc etc..

I can seem to make it stop? I have read it has to do with the OneCLick? what is that? can I just turn it off?

View 3 Replies

Use LINQ To Filter Collection Of Nested Classes To Yield Dictionary Of Unique Properties Of Those Classes?

Jan 23, 2012

I have two classes, one nested in the other. [code]Neither "Name" or "ID" are unique between operations and records.I wish to construct a dictionary using LINQ = Dictionary(Of String, Of List(Of Integer), whereby the keys are uniqe examples of Names in my collection and the values are the collective set of distinct IDs that are associated with those names.

View 2 Replies

[2008] Closed: Entity Framwork - Bind To A Textbox In UI?

Jan 6, 2009

I have a application based on the entity framework. I have extended one of the classes (Quotes) wit 'partial class', and within that i've created a method that is completely independant of any database properties. For simplicity lets say it looks like this:

[code]...

All is good, except i need to bind this to my a textbox in my UI and have the textbox update automatically when the property is changed (like a dependency property). This is proving problamatic, I've tried both invoking the onPropertyChanged sub that the entity framwork exposes and implementing intoifychanged. Both cause errors.

View 3 Replies

VS 2010 Structure Classes So That The User Interfaces Though A Single Class While The Supporting Classes Are Hidden From Their View?

Jun 13, 2012

How can I structure my classes so that the user interfaces though a single class while the supporting classes are hidden from their view? I think its best understood in an example:

Public Class MyInterface
Public Economic as EconomicClass
Public Sub New()
MyBase.New()

[code].....

So you might ask why am I even separating them? It's strictly for others who will be working with this interface. I need to funnel them though a logical structure:

interface.Economic.MyMethod
interface.Currency.MyMethod
etc

This way everything is already handled for them in the background and they only need to run the method they need. I don't know if I can have it both ways in VB.NET.

View 23 Replies

VS 2010 Calling Subs And Functions Within Classes That Are Within Classes?

Oct 24, 2009

Here is some example code of what I mean:

vb
Public Class Form1
Private Sub Button1_Click(ByVal sender as Object, e as systemEventArgs) Handles Button1.Click

[Code]....

View 5 Replies

Derived Classes Cannot Raise Base Classes

Jul 10, 2009

I m trying to raise Click event of Textbox explictly but I m getting "Derived classes cannot raise base classes" error.[code]....

View 1 Replies

C# - Are Microsoft Entity Framework And ADO.NET Entity Framework (.edmx) The Same

May 13, 2010

c# - Are Microsoft Entity Framework and ADO.NET Entity Framework (.edmx) the same?

View 7 Replies

VS 2008 Do New Classes 'leak'?

Jul 15, 2009

If I have something like this within a sub/function:Dim a as new myclass...Does this leave a memory leak if I am constantly calling this function creating new instances of this class? Do I have to destroy it or something when I am done using it?

View 2 Replies

VS 2008 Invoke In Classes

Oct 6, 2009

I have a Tcp Client which I created on an application form but now I would like to create a class for it.

My prob is that when I check for any incoming data, I used to start a new thread. When this new thread finds any incoming data, I call a sub which invokes the form and everything works smooth.

This is what I am talking about,[code...]

How would I be able to do the same from a class? Or I dont have to create a separate thread when using classes?

View 2 Replies

Declare An Array Of Classes In VB 2008?

May 3, 2009

I have built a new class lets say it is called class1

Public
Class Class1
Public s As String ' strings
End

now in my program I want to create an array of them in on the windows form, how do I do this?Class

View 2 Replies

VB 2008 LINQ To SQL Classes - How To Use App Role

Feb 18, 2010

I am curious as to the proper technique to use SQL Server's AppRole with a LINQ to SQL Class. I understand I have to establish the intial connection with no connection pooling. However, do I simply call the SQL stored procedure sp_setapprole using standard LINQ before executing any of my methods that interact with the database, or is there a better way to enable and use AppRole within the LINQ to SQL class?

View 6 Replies

VS 2008 Install WMI SDK Or Maybe WMI Win32 Classes?

May 14, 2009

I'm running into is some of the namespaces aren't being recognized. After searching the internet it seems I am supposed to have more than just System.Management.Instrumentation available to Import/Reference.However, that is all I can access.I need System. Management. ConnectionOptions and a few others, but don't know how to get these.Do I need to install the WMI SDK, or maybe the WMI Win32 Classes?

View 2 Replies







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