public DataTable getEmployee(EmployeeModel Query,EmployeeModel Where)
{
//I hae extra SQLClass which create select and where stamement from as SQL Queries based on hashtable.
mySQL.Select(Query.getField(),Where.getFields()) ///Creates SQL and excedute
}
}
class businessLayerEmployee
{
EmployeeModel Query=new EmployeeModel();
EmployeeModel Where=new EmployeeModel();
public DataTable getEmployee()
{
Query.Name; //Onyly Return Name from table
Where.Name='ABCD' ///Return All the querties on where containing ABCD.
}
}
As you can see that I have felexible Class that what ever query on what condition my SQL class generates and its working fine on Single table ... Know I want to join tables on use LINQ to do it... I want to pass Customised conditon and required number of
fields then How can I do that ..
If I need to create separate function to select seperate column according to my knowledge i have current.
What exactly I want DataTable dtEmployee=objEmployee.sqlTable;
DataTable dtAttendance=objQuery.Table;
// DataTable JoinedTable=new DataTable();
var query=from t1 in dtEmployee.AsEnumerable() join t2 in dtAttendance.AsEnumerable() on t1.Field<string>(entEmployee.EmployeeCode) equals t2.Field<string>(entAttendance_Exclude.employeeCode)
select new
{
entEmployee.EmployeeCode,
entAttendance_Exclude.advanceAmount,
entAttendance_Exclude.currency,
entAttendance_Exclude.dateFrom,
entAttendance_Exclude.dateTo,
entAttendance_Exclude.ID,
entAttendance_Exclude.remarks
};
DataTable attendanceExecuation = Converter<DataTable>(query);
I need to modify this function I can use this more than once on more than one Condition
If I want to return only name then only Name will came up if I need remarks then only one Remarks come up like and customised where statement... as exactly follows
What exactly I want DataTable dtEmployee=objEmployee.sqlTable;
DataTable dtAttendance=objQuery.Table;
// DataTable JoinedTable=new DataTable();
var query=from t1 in dtEmployee.AsEnumerable() join t2 in dtAttendance.AsEnumerable() on t1.Field<string>(entEmployee.EmployeeCode) equals t2.Field<string>(entAttendance_Exclude.employeeCode)
where SQL.GenerateWhere(this function will generate where statement on SAQLClass and return string based on presentation Layer.
select new
{
Number of Filed will return which is passed from presentation layer not all the fields. Id I will not pass any thing then all fields will return
};
DataTable attendanceExecuation = Converter<DataTable>(query);
According to your description, I suggest you using EntityFramework, because it has offered you a very nice solution to One-To-Many or Many-To-Many part. And it's not an easy task to cope with relationship between tables.
What's more, if you'd like to write codes to create models, you can just use EntityFramework (Code-First) to deal with them, for more you can see:
Minhajul0401...
Member
77 Points
121 Posts
LINQ to SQL entities
Nov 02, 2012 09:56 AM|LINK
Hi All
I have 3 tier application as followis
class employeeEntity
{
public string Name{get { return "Name"}}
public string EmpCode{get{return "empCode"}}
}
string _Name;
class EmployeeModel
{
public string Name
{
get{return _Name;}
set{ _Name=value};
//Insert into hashtable
}
string _empCode;
public string EmpCode
{
get{return _Name;}
set{ _Name=value};
//Insert into hashtable
}
public HashTable getFields()
{
return __fields;
}
}
class businessLayerEmployee
{
public DataTable getEmployee(EmployeeModel Query,EmployeeModel Where)
{
//I hae extra SQLClass which create select and where stamement from as SQL Queries based on hashtable.
mySQL.Select(Query.getField(),Where.getFields()) ///Creates SQL and excedute
}
}
class businessLayerEmployee
{
EmployeeModel Query=new EmployeeModel();
EmployeeModel Where=new EmployeeModel();
public DataTable getEmployee()
{
Query.Name; //Onyly Return Name from table
Where.Name='ABCD' ///Return All the querties on where containing ABCD.
}
}
As you can see that I have felexible Class that what ever query on what condition my SQL class generates and its working fine on Single table ... Know I want to join tables on use LINQ to do it... I want to pass Customised conditon and required number of fields then How can I do that ..
If I need to create separate function to select seperate column according to my knowledge i have current.
What exactly I want DataTable dtEmployee=objEmployee.sqlTable;
DataTable dtAttendance=objQuery.Table;
// DataTable JoinedTable=new DataTable();
var query=from t1 in dtEmployee.AsEnumerable() join t2 in dtAttendance.AsEnumerable() on t1.Field<string>(entEmployee.EmployeeCode) equals t2.Field<string>(entAttendance_Exclude.employeeCode)
select new
{
entEmployee.EmployeeCode,
entAttendance_Exclude.advanceAmount,
entAttendance_Exclude.currency,
entAttendance_Exclude.dateFrom,
entAttendance_Exclude.dateTo,
entAttendance_Exclude.ID,
entAttendance_Exclude.remarks
};
DataTable attendanceExecuation = Converter<DataTable>(query);
I need to modify this function I can use this more than once on more than one Condition
If I want to return only name then only Name will came up if I need remarks then only one Remarks come up like and customised where statement... as exactly follows
What exactly I want DataTable dtEmployee=objEmployee.sqlTable;
DataTable dtAttendance=objQuery.Table;
// DataTable JoinedTable=new DataTable();
var query=from t1 in dtEmployee.AsEnumerable() join t2 in dtAttendance.AsEnumerable() on t1.Field<string>(entEmployee.EmployeeCode) equals t2.Field<string>(entAttendance_Exclude.employeeCode)
where SQL.GenerateWhere(this function will generate where statement on SAQLClass and return string based on presentation Layer.
select new
{
Number of Filed will return which is passed from presentation layer not all the fields. Id I will not pass any thing then all fields will return
};
DataTable attendanceExecuation = Converter<DataTable>(query);
Please advise my how to fo that.
Thanks
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: LINQ to SQL entities
Nov 03, 2012 01:05 AM|LINK
Hello,
According to your description, I suggest you using EntityFramework, because it has offered you a very nice solution to One-To-Many or Many-To-Many part. And it's not an easy task to cope with relationship between tables.
What's more, if you'd like to write codes to create models, you can just use EntityFramework (Code-First) to deal with them, for more you can see:
http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx