score:12
Accepted answer
you can do something like this:
public interface ientity<t>
{
iqueryable<t> getall();
}
public class dealer : ientity<dealer>
{
public iqueryable<dealer> getall() { }
}
score:1
adding save()
, validate()
, etc. logic to your domain object (which is what a dealer
is, i guess) is not the best idea in the world as it violates srp.
score:3
you just need to make ientity generic itself. then, use the type parameter in the definition of getall().
here's how you'd change your code:
public interface ientity<tlistitemtype>
{
// stuff snipped
iqueryable<tlistitemtype> getall();
}
public class dealer : ientity<dealer>
{
public iqueryable<dealer> getall() { // some impl here }
}
Source: stackoverflow.com
Related Query
- Generic list in an interface
- List or Array of String Contain specific word in Html Source Code
- c# Linq or code to extract groups from a single list of source data
- How can I sort generic list DESC and ASC?
- Subtract a generic list from another
- Convert DataTable to Generic List in C#
- Find an item in a generic list by specifying multiple conditions
- How to use .Where in generic list
- Simplest way to filter value from generic List in C# using LINQ
- Gridview using a generic list as DataSource and Auto-generating columns
- Converting a XML to Generic List
- Generic List to EntitySet Conversion
- Cast Entity to Implemented Interface in a Generic Method Using LINQ for Entity Framework
- Generic List .First not working LINQ
- Generating the Shortest Regex Dynamically from a source List of Strings
- Visual Studio Code Analysis Rule - "Do not expose generic lists"
- Auto-incrementing a generic list using LINQ in C#
- Remove a property/column from a generic list
- Generic List to CSV String
- C# Generic List Union Question
- Delete an element from a generic list
- Linq OrderBy on generic list returns not entirely alphabetical list
- Sorting a generic list by an external sort order
- How to convert Generic List<anonymous type > to Generic List <Classname>?
- Execute method for each object in generic list using lambda
- LINQ Source Code Available
- C# Interface IEnumerable Any() without specifying generic types
- Checking for item in Generic List before using it
- Removing Duplicates from bottom of Generic List
- How to cast a generic T in repository<T> to an interface to access an interface property conditionally in a LINQ to SQL filter?
More Query from same tag
- C# GroupByMany to List-of-Lists
- Filtering Nodes and Join with other element to get caption
- Multiple WHERE Clauses with LINQ extension methods
- LINQ - nested SelectMany as Query Syntax
- Filtering lambda expression that compares two elements of the same collection
- does c# null-conditional operator works with linq methods
- How to group C# class object values. Is this possible with LINQ?
- Creating Collection of Class Object
- Best Data Access Technology in MVC4 and MVC5
- How to show the filenames under the selected folder on the Radio Button
- Expression tree to initialize new anonymous object with arbitrary number of properties
- Linq to Entities: .Clear() does not delete relation row, only relation column value
- LINQ to SQL - Save an entity without creating a new DataContext?
- Recursive LINQ calls
- SQL LIKE in Linq
- LINQ, Grouping on IEnumerable<object[]>
- How to calculate if date in database has expired within LINQ
- Can I add numerically the values of two arrays using LINQ?
- LINQ with Group, Join and Where Easy in SQL not in LINQ?
- Does not contain a definition for 'where' and the best extension method overload
- ASP.NET Core 5 and EF - InvalidOperationException
- How do I write a linq select statement without knowing at design time the names of the properties I'm going to select?
- LINQ query not working properly
- Optimizing LINQ to Sharepoint
- Use Linq to get the last order placed yesterday for each customer
- Technique for dynamically adding a join to a linq query?
- SQL to LINQ Expression
- How to fill an Windows Forms combobox using DbfDotNet?
- C# Linq alternative for lodash omit function
- Linq - Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement>' to 'System.Collections.Generic.List<string>'