TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ramco Ramco
442
3.4k
528.7k
Consume Api using RestSharp
Feb 21 2021 4:03 AM
Hi
I have 1 Solution with 3 NameSpaces.
Data Access Layer
public partial class Employee
{
public int ID { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public string Gender { get; set; }
public Nullable<int> Salary { get; set; }
public Nullable<int> DepartmentId { get; set; }
public string Active { get; set; }
public Nullable<System.DateTime> CreatedOn { get; set; }
public Nullable<System.DateTime> UpdatedOn { get; set; }
//public Department Department { get; set; }
public virtual Department Department { get; set; }
}
public partial class Department
{
public int ID { get; set; }
public string ShortName { get; set; }
public string Description { get; set; }
public virtual ICollection<Employee> Employees { get; set; }
}
API Controller
------------------
namespace ProjectManagement.Controllers
{
public class EmployeesController : ApiController
{
private PMDbEntities db = new PMDbEntities();
// GET: api/Employees
public IHttpActionResult GetEmployees()
{
try
{
var results = (from d in db.Employees
join f in db.Departments
on d.DepartmentId equals f.ID
select new
{
Id = d.ID,
Name = d.Name,
Department = f.Description
}).ToList();
if (results == null)
{
return NotFound();
}
return Ok(results);
}
catch (Exception)
{
return BadRequest();
}
}
}}
AT Client side i want to display data using RestSharp in Jquery Datatable.
Secondly do i need to create same Models at Client Side also or i can add Reference of Data Access Layer.
Thanks
Reply
Answers (
3
)
Difference between DataSet and DataReader.
How to pass Data to Web Api