0

I have a class named Employee:

public enum EmploymentStatus
{ FullTime,PartTime,Unknown };

public class Employee
{
 private long emplNbr;
 private string name;
 private EmploymentStatus st;
 private double wage;

 public long EmployeeNumber
 {
    get { return emplNbr; }
    set { emplNbr = value; }
 }

 public string EmployeeName
 {
    get { return name; }
    set { name = value; }
 }

 public EmploymentStatus Status
 {
    get { return st; }
    set { st = value; }
 }

 public double HourlySalary
 {
    get { return wage; }
    set { wage = value; }
 }
}

I want to learn how to generate LINQ query at runtime using this class by passing the object to whatever function , void , .. any thing with appointing the query type (insert,update,delete,select) and retrieving the LINQ query in runtime.

Drew Kennedy
  • 4,118
  • 4
  • 24
  • 34
  • 2
    Your question is unclear. What exactly do you want to achieve? (Note: Your code can be shortened by using [auto-implemented properties](http://stackoverflow.com/q/6001917/87698).) – Heinzi Mar 07 '15 at 15:49
  • 1
    https://i.imgflip.com/ijqk1.jpg – Millie Smith Mar 07 '15 at 15:51
  • i want to pass class object to function and return linq query like the following public string fun(string querytype, Employee emp) { // auto generate LINQ query using emp object return LINQ_query; } to invock it fun("select",new Employee emp); – Mohamed Mohamed Mar 07 '15 at 16:07
  • 2
    @MohamedMohamed: Can you give an example of what a LINQ query is to you? It doesn't make any sense to "auto generate a linq query".. – Patrick Mar 07 '15 at 16:16
  • I think he's looking for something like a [PredicateBuilder](http://www.albahari.com/nutshell/predicatebuilder.aspx) – Jan Köhler Mar 07 '15 at 16:25
  • Your question is far from clear. For one, LINQ is for strict queries; i.e. it doesn't do "insert, update, delete", just "select". For another, what _exactly_ do you expect the output of your hypothetical code to produce? Please see http://stackoverflow.com/help/how-to-ask for advice on how to edit your question so that it can be answered. – Peter Duniho Mar 07 '15 at 16:35

0 Answers0