Use the following reference to help you learn about each of the classes and funcations
What is use of MyResult class?
MyResult is very usefull class. It is very important class for understanding. Mostly every function will return this class with diffrent type of data.
MyResult will profile following data as per requirement.
-
AffectedRows: Provide result of affected rows with transaction
-
IsSuccess: Provide result of wether transaction is succeed or not
-
Message: Provide message of success of error (This is header of message or it self message)
-
DetailMessages: It will provide multiple detail of errors
-
DetailError: You can manage error handling here with below property Even you can send mail or some database entry from here for error handling perpose.
-
dsetData: Provide multiple DataTable with result
-
paging: Paging class will provide detail paging data
-
TotalRecords: Total number of records with the execute query
-
TotalPages: Total number of pages with the execute query
-
PageSize: Provide number of page size
-
PageIndex: First record index of current page
-
FirstRecordIndex: First record index of current page
-
LastRecordIndex: Last record index of current page
-
SortField: Provide default sort field or provided sort field from funcation
-
SortType: Provide default sort type or provided sort field from funcation
SQLHelper - Fetch Multiple Tables
SQLHelper - Fetch Data With Stored Procedure or only Execute Stored Procedure - Without Parameters
-
Just pass your srore procedure's name with GetTableBySP funcation. Your procedure should not have any parameters.
You can fetch data or just execute your store procedure
MyResult result = SqlHelper.GetTableBySP("YourStoreProcedureName");
SQLHelper - Fetch Data With Stored Procedure With Parameters
-
You can fetch data with your own function and pass sql parameters to like below function
public DataSet OwnFunction(int ID, string Name)
{
DataSet dsetData = new DataSet();
SqlParameter[] sqlParams = new SqlParameter[2];
sqlParams[0] = DbParameter("@ID", ID);
sqlParams[1] = DbParameter("@Name", Name);
dsetData = ExecuteDataset(CommandType.StoredProcedure, "YourStoreProcedureName", sqlParams);
return dsetData;
}
dTable - Get Data With Different Criteria
dTable class has following parameter for functions.
Kindly first take a look with it so you can eaily understand all methods.
-
TableName: Provide table name or SQL View name
-
Columns: Provide column name saparate by comma (as per our sql select query)
-
Where: Provide where caluse
-
Sort: Provide sort column name
-
SortType: Provide sort type (ASC or DESC)
-
PageIndex: Provide current page index
-
PageSize: Provide page size
Note: You can't make join with this dTable class. If you want to do transaction with joins then please make SQL views or use jTable class.
You can fetch data with diffrent criteria. Ex. Custome columns, Column sorting and paging.
-
Select All Rows With All function
MyResult result = dTable.All("TableName");
-
Fetch data with Select function
MyResult result = dTable.Select("TableName");
MyResult result = dTable.Select("TableName", "Columns");
MyResult result = dTable.Select("TableName", "Columns", "Where");
MyResult result = dTable.Select("TableName", "Columns", "Sort", "SortType");
MyResult result = dTable.Select("TableName", "Columns", "Where", "Sort", "SortType");
Select function is very usefull and it has five overload methods.
All parameters description is above this function.
-
Fetch data with Where function
MyResult result = dTable.Where("TableName", "Where");
MyResult result = dTable.Where("TableName", "Where", "Columns");
MyResult result = dTable.Where("TableName", "Where", "Columns", "Sort", "SortType");
-
Fetch data with OrderBy function
MyResult result = dTable.OrderBy("TableName", "Sort", "SortType");
MyResult result = dTable.OrderBy("TableName", "Sort", "SortType", "Columns");
MyResult result = dTable.OrderBy("TableName", "Sort", "SortType", "Columns", "Where");
-
Fetch data with Paged function
MyResult result = dTable.Paged("TableName", "PageIndex", "PageSize");
MyResult result = dTable.Paged("TableName", "PageIndex", "PageSize", "Columns");
MyResult result = dTable.Paged("TableName", "PageIndex", "PageSize", "Columns", , "Where");
MyResult result = dTable.Paged("TableName", "PageIndex", "PageSize", "Columns", , "Where", "Sort", "SortType");
You can fetch data with paging and you paging result will return with MyResult class.
PageIndex you require to pass your current page index. which you require to show in list.
PageSize pass your current page size.
jTable - Get Data With Different Criteria and Joins
jTable class has two constroctor. one has pass only table name which is same as only dTable class.
Second one is SqlJoin class. SqlJoin class has following parameters
Info: All dTable and jTable class has same method only diffrent is joins and jTable class has own constructor while dTable class has all methods are static.
Following are some Example for how to use jTable calss.
-
Simple Select method with jTable class with single join
MyResult result = new jTable("Student",
new SqlJoin(SqlJoinType.Left, "Class", "ID", "Student", "ClassID"))
.Select("Student.ID, Student.Name, Class.Name, Student.DOB");
-
Simple Select method with jTable class with multiple join
MyResult result = new jTable("Student",
new SqlJoin(SqlJoinType.Left, "Class", "ID", "Student", "ClassID"),
new SqlJoin(SqlJoinType.Left, "Book", "ID", "Student", "BookID"))
.Select("Student.ID, Student.Name, Class.Name, Book.Name, Student.DOB");
Note: As per before information all jTable has same method of dTable. so you can do any operation with table.