Click here to Skip to main content
15,903,388 members
Home / Discussions / C#
   

C#

 
GeneralRe: convert raw image to bmp or jpeg Pin
Christian Graus22-Feb-07 8:54
protectorChristian Graus22-Feb-07 8:54 
Questioncalling a random number only once Pin
alostdruid21-Feb-07 17:13
alostdruid21-Feb-07 17:13 
AnswerRe: calling a random number only once Pin
Shajeel21-Feb-07 18:00
Shajeel21-Feb-07 18:00 
AnswerRe: calling a random number only once Pin
Christian Graus21-Feb-07 18:26
protectorChristian Graus21-Feb-07 18:26 
Questionremoting Pin
kalyan_241621-Feb-07 16:59
kalyan_241621-Feb-07 16:59 
QuestionHow can I know what ChildNode is selected from TreeView? [modified] Pin
Khoramdin21-Feb-07 16:14
Khoramdin21-Feb-07 16:14 
AnswerRe: How can I know what ChildNode is selected from TreeView? Pin
Shajeel21-Feb-07 18:28
Shajeel21-Feb-07 18:28 
QuestionC# Question with Generics [modified] Pin
malharone21-Feb-07 15:04
malharone21-Feb-07 15:04 
I have an object hierarchy where all of my objects in the application domain inherit from a base class. I also have a persistance layer which works using generics.

Looking at the code below, you realize that my object hierarchy is non-generic. But DBStore methods are genericised. How do I pass the type/class of current type?
e.g.
class DBStore
{
  public T CreateObject<T>()
  {
    ...
  }
  public void DeleteObject<T> (int id)
  {
     .. logic to delete from DB using metadata about T (containing table name) and primary key field matching 'id' ...
     .. eg.. delete from typeof(T).Name where ID = id
  }
}
abstract class DomainObject
{
  private int _id;
  private DBStore _dbStore;
  public void Delete ()
  {
    _dbStore.DeleteObject<<big>WHAT SHOULD GO HERE</big>>(_id)
  }
}
class Boat : DomainObject {...}
class Car : DomainObject {...}


I would like to be able to perform following:

Car car = new Car();
car.Delete();

or
Boat boat = new Boat();
boat.Delete();


Only things that come to my mind are:
1) Move "Delete" method from the base class to each of the deriving class: (code redundancy .. Sigh | :sigh: )
2) Ungenerecise the "DBStore" method (inconsistancy in DBStore -- all methods are generic, except for Delete object)

Thanks,

- Malhar
AnswerRe: C# Question with Generics Pin
Christian Graus21-Feb-07 15:12
protectorChristian Graus21-Feb-07 15:12 
GeneralRe: C# Question with Generics [modified] Pin
malharone21-Feb-07 15:16
malharone21-Feb-07 15:16 
GeneralRe: C# Question with Generics Pin
Christian Graus21-Feb-07 16:02
protectorChristian Graus21-Feb-07 16:02 
GeneralRe: C# Question with Generics Pin
mike montagne26-Feb-07 14:53
mike montagne26-Feb-07 14:53 
GeneralRe: C# Question with Generics Pin
malharone27-Feb-07 11:13
malharone27-Feb-07 11:13 
GeneralRe: C# Question with Generics Pin
mike montagne27-Feb-07 13:36
mike montagne27-Feb-07 13:36 
GeneralRe: C# Question with Generics Pin
malharone27-Feb-07 13:48
malharone27-Feb-07 13:48 
GeneralRe: C# Question with Generics Pin
mike montagne27-Feb-07 13:47
mike montagne27-Feb-07 13:47 
GeneralRe: C# Question with Generics Pin
malharone27-Feb-07 14:01
malharone27-Feb-07 14:01 
GeneralRe: C# Question with Generics Pin
mike montagne27-Feb-07 19:24
mike montagne27-Feb-07 19:24 
GeneralRe: C# Question with Generics Pin
mike montagne28-Feb-07 6:25
mike montagne28-Feb-07 6:25 
GeneralRe: C# Question with Generics Pin
mike montagne28-Feb-07 7:06
mike montagne28-Feb-07 7:06 
GeneralRe: C# Question with Generics Pin
mike montagne28-Feb-07 7:09
mike montagne28-Feb-07 7:09 
GeneralRe: C# Question with Generics Pin
mike montagne28-Feb-07 8:14
mike montagne28-Feb-07 8:14 
AnswerRe: C# Question with Generics Pin
Colin Angus Mackay21-Feb-07 22:09
Colin Angus Mackay21-Feb-07 22:09 
GeneralRe: C# Question with Generics Pin
malharone22-Feb-07 7:03
malharone22-Feb-07 7:03 
AnswerRe: C# Question with Generics Pin
darkelv22-Feb-07 0:42
darkelv22-Feb-07 0:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.