Anyway back to the point - here is some very basic sample Code using LINQ as the Business Logic layer with partial classes to extend the generated SQLMetal classes (aka the classes from the generated dbml file):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LendLease.ManagementReporting.Service.DataContract.DTO;
namespace LendLease.MRP.Service.Persistence.Entity
{
public partial class Ctl_Person_Resp
{
public string UserName
{
get { return this.Dim_User.First_Name + " " + this.Dim_User.Last_Name; }
}
/// <summary>
/// Gets list of People who have responsibility in the current level of the hierarchy.
/// </summary>
/// <param name="businessHierarchyId"></param>
/// <returns></returns>
public static List<PersonResponsibleListDTO> GetPersonResponsibleList(int businessHierarchyId)
{
MRPDataContext context = new MRPDataContext();
//Join to the the member code so we can filter the person responsible list
var query = from person in context.Ctl_Person_Resps
join hierarchy in context.Dim_Business_Hierarchy_PCs on person.Business_Hierarchy_PC_Member_Code equals hierarchy.Member_Code
where hierarchy.Business_Hierarchy_PC_SKEY == businessHierarchyId
select new PersonResponsibleListDTO { User_SKEY = person.User_SKEY, UserName = person.UserName};
return query.Distinct().ToList<PersonResponsibleListDTO>();
}
}
}
No comments:
Post a Comment