C# LINQ Custom Provider to SQL

I want to use a custom LINQ provider to replace 'Parameter' object functionality that I've had in my Repository queries until now. These parameter objects took the following kind of form:



Id { get; set; }

LastName { get; set; }

FirstName { get; set; }


This object gets passed into the repository's Query(PersonParameters) method which in turn get forwarded it on to the DAL which would build an SQL query.

The recordset output from this query got passed to an ObjectBuilder that constructs a Person objects which satisfy the parameters.

I want to change these Query(PersonParameters) methods to return an IQueryable<T> to give me the flexibility of LINQ to replace the Parameter objects that build the SQL query.

What I'm looking for is someone to create a QueryProvider that will take a Dictionary<string, string> that will map the incoming predicate's arguments to a database field.

For example, if the following classes existed:



string Name { get; set; }

int NumberOfLegs { get; set; }

Species Species { get; set; }




string Name { get; set; }




IQueryable<Animal> Query();


I'd be able to write a query that looked like this:

var animalRepository = new Repository<Animal>();

var query = [url removed, login to view]().Where(T=>T.NumberOfLegs=4 && [url removed, login to view] == "Lion").OrderBy(T=>[url removed, login to view]);

I want a QueryProvider that will generate SQL with properties mapped to custom SQL field names.

For example consider the following interface:

IQueryMap {

string TableName { get; }

string[] TablesFields { get; }

Dictionary<string, string> Mappings { get; }


An object that inherits this interface could be created with the following properties set:

TableName = "AllTheAnimals";

TablesFields = new string[] { "id", "animalName", "animalsNumberOfLegs", "theAnimalSpeciesName", "amountOfFur" };

Mappings = new Dictionary<string,string>();

[url removed, login to view]("Name", "animalName");

[url removed, login to view]("NumberOfLegs", "animalsNumberOfLegs");

[url removed, login to view]("Species.Name", "theAnimalSpeciesName");

If this object were passed into the provider along with the query from above it would generate SQL that looks like this:

SELECT animalName, animalsNumberOfLegs, theAnimalSpeciesName, amountOfFur

FROM AllTheAnimals t0

WHERE [url removed, login to view] = 4 AND [url removed, login to view] = "Lion"

ORDER BY [url removed, login to view]

So essentially I want to create my own mapping objects that will be passed into the QueryProvider that map the LINQ query to SQL field names.

I will then create the objects manually from the QueryProvider recordset enumerator.

I've been referring to a microsoft tutorial here:

[url removed, login to view]

but have gotten confused by Expressions, ExpressionVisitors, etc etc etc etc

I'll send through interfaces that I'm programming against for your reference.

Many thanks

Kemahiran: .NET, Pengaturcaraan C#

Lihat lagi: custom linq provider, custom linq sql provider, custom provider, orderby custom, custom linq, custom linq sql, linq sql database custom provider, custom repository linq, linq provider, sql custom provider, linq select custom, linq object sql, custom object provider, custom queryprovider, custom query provider, custom iqueryable provider, linq custom sql, custom linq provider sql, what is a string in programming, what is an object in programming, want to create my own database, tutorial string, tutorial programming, tutorial on programming, tutorial in programming

Tentang Majikan:
( 10 ulasan ) London, United Kingdom

ID Projek: #1602094

Dianugerahkan kepada:


Hello Sir, please checkout my message

£250 GBP dalam 4 hari
(77 Ulasan)

8 pekerja bebas membida secara purata £223 untuk pekerjaan ini


Hello, i have 8 years experince in c#

£400 GBP dalam 10 hari
(42 Ulasan)

Hi, I have gone through your requirement and I am glad that We can accomplish this task, Please give us opportunity to work with you. Please check PM . Thanks, TTS Team

£150 GBP dalam 5 hari
(33 Ulasan)

Please see pmb

£250 GBP dalam 4 hari
(2 Ulasan)

Greetings, we are one of the India's highly skilled web technology experts. We specialize in giving an App idea a concrete shape with a Guarantee of Excellence, Quick turnaround and Cost-effectiveness. We strive har Lagi

£225 GBP dalam 2 hari
(0 Ulasan)

Hi, Alvicreatives has been long into web application development & designing and development business. The last 5 years, we are working on web based ASP.net / C#, Sqlserver 2005/2008, Ajax, CSS, Flash,PHP,MySql,Wor Lagi

£190 GBP dalam 3 hari
(0 Ulasan)

Expert C#/LINQ/SQL developer. plesae see PMB.

£170 GBP dalam sehari
(0 Ulasan)


£150 GBP dalam 3 hari
(0 Ulasan)