Find Jobs
Hire Freelancers

C# LINQ Custom Provider to SQL

£20-250 GBP

In Progress
Posted almost 12 years ago

£20-250 GBP

Paid on delivery
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: PersonParameters { 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: Animal { string Name { get; set; } int NumberOfLegs { get; set; } Species Species { get; set; } } Species { string Name { get; set; } } Repository<Animal> { IQueryable<Animal> Query(); } I'd be able to write a query that looked like this: var animalRepository = new Repository<Animal>(); var query = [login to view URL]().Where(T=>T.NumberOfLegs=4 && [login to view URL] == "Lion").OrderBy(T=>[login to view URL]); 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>(); [login to view URL]("Name", "animalName"); [login to view URL]("NumberOfLegs", "animalsNumberOfLegs"); [login to view URL]("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 [login to view URL] = 4 AND [login to view URL] = "Lion" ORDER BY [login to view URL] 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: [login to view URL] 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
Project ID: 1602094

About the project

8 proposals
Remote project
Active 12 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
Hello Sir, please checkout my message
£250 GBP in 4 days
5.0 (77 reviews)
7.1
7.1
8 freelancers are bidding on average £223 GBP for this job
User Avatar
Hello, i have 8 years experince in c#
£400 GBP in 10 days
5.0 (42 reviews)
6.6
6.6
User Avatar
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 in 5 days
4.9 (33 reviews)
5.2
5.2
User Avatar
Please see pmb
£250 GBP in 4 days
5.0 (2 reviews)
2.2
2.2
User Avatar
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,WordPress,Ecommerce & SEO projects and look forward to concentrate on such projects only. As per your project, we give the cost & time frame for a milestone. Our team matches the required skill set and thus we are confident in taking up this assignment. I look forward to hear from you. Best Regards, Team, Alvicreatives.
£190 GBP in 3 days
0.0 (0 reviews)
0.0
0.0
User Avatar
Expert C#/LINQ/SQL developer. plesae see PMB.
£170 GBP in 1 day
0.0 (0 reviews)
0.0
0.0
User Avatar
PLEASE CHECK PMB
£150 GBP in 3 days
0.0 (0 reviews)
0.0
0.0

About the client

Flag of UNITED KINGDOM
London, United Kingdom
5.0
10
Payment method verified
Member since May 2, 2012

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.