generic

Cascading IEquatable(Of T)

Hello! I have several entities I need to make IEquatable(Of TEntity) respectively. I want them first to check equality between EntityId, then if both are zero, should check regarding to other properties, for example same contact names, same phone number etc. How is this done? ...

C# Calling Methods in Generic Classes

I am extending the ImageBox control from EmguCV. The control's Image property can be set to anything implementing the IImage interface. All of the following implement this interface: Image<Bgr, Byte> Image<Ycc, Byte> Image<Hsv, Byte> Now I want to call the Draw method on the object of the above type (what ever it may be). The probl...

How could I pass the type using Variables to the generic method???

Hi All, I have a generic method in c#: public IList<T> getList<T>(); When I call it as the way below? ... Type T1=metadata.ModelType; getList<T1>(); ... I got error in compiling. How could I do for it? I really need to pass the type as Variables to the generic method! ...

write a function using generic

hi,guy, i want write a function using c#, and it accept any type parameter,i want use generic list to do, but i can't finish, it's wrong, how to do it? perhaps there are other ways?? thinks! public class City { public int Id; public int? ParentId; public string CityName; } public class ProductCategory { public int Id;...

IQueryable IGrouping how to work

i return such type IQueryable< IGrouping<int, Invoice>> List() how can i work with it? like with generic List<Invoice> ? ...

Generic List created at runtime

Hi... i neeed something like this in C#.. have list in class but decide what will be in list during runtime class A { List<?> data; Type typeOfDataInList; } public void FillData<DataTyp>(DataTyp[] data) where DataTyp : struct { A a = new A(); A.vListuBudouDataTypu = typeof(DataTyp); A.data = new List<A.typeOfDataInL...

Scala Generic Function Values (Anonymous Function) - Missing Parameter Type (Error)

Hi all, im new with SCALA (Scala code runner version 2.7.7.final), and i really dont understand why scala requires for the caller the parameter type when we are using high order functions. The sample below , i have one stand alone object ( Util ) that have one function. The Main block, the caller must pass the parameter type to the ano...

XQuery to get a list of all attributes an element has

Hi! Is there a generic way of determining all attributes (and their values) from an XML node using XQuery/XPath? thx, Alex ...

How to simply a foreach iteration using reflection

Consider that I have to get the overall performance of X. X has Y elements and Y in turn has Z elements which inturn has some N elements. To get the performance of X I do this: List<double> XQ = new List<double>(); foreach (Elem Y in X.Y){ List<double> YQ = new List<double>(); foreach (Elem Z in Y.Z){ List<double> ZQ = new L...

Generic Singleton Façade design pattern

Hi I try write singleton façade pattern with generics. I have one problem, how can I call method from generic variable. Something like this: T1 t1 = new T1(); //call method from t1 t1.Method(); In method SingletonFasadeMethod I have compile error: Error 1 'T1' does not contain a definition for 'Method' and no extension method 'Method...

Get the type name

How i can get full right name of generic type? For example: This code typeof(List<string>).Name return List`1 instead of List<string> How to get a right name? typeof(List<string>).ToString() returns System.Collections.Generic.List`1[System.String] but i want to get initial name: List<string> Is it real? ...

What .Net Namespace contains Entity for use in a generic repository?

I have a question that I'm ashamed to ask, but I'm going to have a go at it anyway. I am creating a generic repository in asp.net mvc. I came across an example on this website which I find to be exactly what I was looking for, but there is one problem. It references an object - Entity - and I don't know what namespace it is in. I typical...

C#: Preferred pattern for functions requiring arguments that implement two interfaces

The argument to my function f() must implement two different interfaces that are not related to each other by inheritance, IFoo and IBar. I know of two different ways of doing this. The first is to declare an empty interface that inherits from both: public interface IFooBar : IFoo, IBar { // nothing to see here } public int f(IFooB...

.NET C# setting the value of a field defined by a lambda selector

I have a generic class HierarchicalBusinessObject. In the constructor of the class I pass a lambda expression that defines a selector to a field of TModel. protected HierarchicalBusinessObject (Expression<Func<TModel,string>> parentSelector) A call would look like this, for example: public class WorkitemBusinessObject : Hie...

WPF add c# code to customcontrol

I want to create simple custom control (derived from control and with look defined in generics.xaml). I need to change size of elements defined in generic.xaml, when control is resized! It would be great to write some of that generic.xaml part in C#. Is that possible? Or is there a way to create MVVM like custom control? What i am willi...

Django generic relation field reports that all() is getting unexpected keyword argument when no args are passed.

I have a model which can be attached to to other models. class Attachable(models.Model): content_type = models.ForeignKey(ContentType) object_pk = models.TextField() content_object = generic.GenericForeignKey(ct_field="content_type", fk_field="object_pk") class Meta: abstract = True class Flag(Attachable): ...

How can I use generic here.

I am trying to use generic for the first time and trying to typecast my result returned from database to programmer defined data type. How can I do this. dsb.ExecuteQuery("DELETE FROM CurrencyMaster WHERE CurrencyMasterId=" + returnValueFromGrid<int>(getSelectedRowIndex(), "CurrencyMasterId")); private T returnValueFromGrid<T>(...

What is LDAP and when consider to use it in web applications?

Hello, What is LDAP and why people use LDAP instead of rel. DB? I've read some about LDAP on Wikipedia, but I'm still confused what is it. Thank you ...

C# ASP.NET Binding Controls via Generic Method

I have a few web applications that I maintain and I find myself very often writing the same block of code over and over again to bind a GridView to a data source. I'm trying to create a Generic method to handle data binding but I'm having trouble getting it to work with Repeaters and DataLists. Here is the Generic method I have so far: ...

Using Predicate of a class to Search Generic list - Faster than looping?

Lets say we have a generic list of Class1, typically having ~100 objects for a given session. I would like to see if the list has a particular object. ASP.NET 2.0 allows me to do this: Dim objResult as Class1 = objList.Find(objSearch) How does this approach rate when compared to a traditional For loop, looking at a performance perspe...