0
나는 5 개의 레이어로 설계된 솔루션을 가지고 있습니다.DTO를 별도의 프로젝트에서 UI 레이어로 전달 WCF RIA 서비스
그들은 다음과 같습니다
- UI/프리젠 테이션 레이어
- 서비스 레이어
- 비즈니스 로직 계층
- 데이터 액세스 계층
- DTO/공통 층 (IQUTECHDTO)
DTO를 UI에 전달하려고합니다. 아래는 VendorDTO를 반환하고자하는 GetVendors 메소드를 공개하는 서비스 계층입니다. 이 개체는 드롭 다운 상자를 채 웁니다.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.ServiceModel.DomainServices.Hosting;
using System.ServiceModel.DomainServices.Server;
using IQUTechDTO;
using IQUTECHDAL;
namespace BusinessApplication6.Web.Services
{
public class Foos
{
[Key]
public int FooId { get; set; }
public string Name { get; set; }
}
// TODO: Create methods containing your application logic.
[EnableClientAccess()]
public class BillService : DomainService
{
public IEnumerable<Foos> GetFoos()
{
return new List<Foos> { new Foos { FooId = 42, Name = "Fred" } };
}
[Query]
public IEnumerable<VendorDTO> GetVendors()
{
return new List<VendorDTO> { new VendorDTO { VendorID = 42 } };
}
}
}
VendorDTO 유형의 개체를 만들 때 UI .cs 파일에서 볼 수 없습니다. 그러나 UI 레이어에서 Foo 객체에 액세스 할 수있었습니다.
하는 (IQUTECHDTO)를 VendorDTO는 serialazble로 표시되었지만 그러나 별도의 프로젝트에 상주 않습니다
다음using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
using System.ServiceModel.DomainServices;
using System.ServiceModel.Web;
namespace IQUTechDTO
{
public enum LoadStatus
{
Initialized = 0,
Ghost = 1,
Loaded = 2
}
[Serializable]
public class VendorDTO
{
/// <summary>
///DTO for the 'Vendor' object.
/// </summary>
public VendorDTO()
{
this.loadStatus = LoadStatus.Initialized;
}
///<summary>
/// Copy constructor
///</summary>
public VendorDTO(VendorDTO sourceDTO)
{
loadStatus = sourceDTO.loadStatus;
VendorID = sourceDTO.VendorID;
VendorName = sourceDTO.VendorName;
VendorAddress1 = sourceDTO.VendorAddress1;
VendorAddress2 = sourceDTO.VendorAddress2;
VendorCity = sourceDTO.VendorCity;
VendorState = sourceDTO.VendorState;
VendorEmail = sourceDTO.VendorEmail;
VendorPhone = sourceDTO.VendorPhone;
VendorPOC = sourceDTO.VendorPOC;
VendorRegion = sourceDTO.VendorRegion;
}
public LoadStatus loadStatus;
[Key]
public int VendorID { get; set; }
public string VendorName;
private string VendorAddress1;
private string VendorAddress2;
private string VendorEmail;
private string VendorPhone;
private string VendorCity;
private string VendorState;
private string VendorPOC;
private string VendorRegion;
}
}
는 UI 클래스
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using BusinessApplication6.Web.Services;
using System.ServiceModel.DomainServices.Client;
using BusinessApplication6.Web;
namespace BusinessApplication6.Views.BOM
{
public partial class BOMCRUD : Page
{
public BOMCRUD()
{
InitializeComponent();
LoadTree();
}
public void LoadTree()
{
BillContext newCon = new BillContext();
//This works
Foos fooobj = new Foos();
//This doesnt work
VendorDTO vendorobj = new VendorDTO();
}
// Executes when the user navigates to this page.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
}
}
왜 그것은 나를이 개체에 액세스 할 수 없습니다 .
도움을 주시면 감사하겠습니다.
감사 톰
IQUTECHDTO에 프로젝트 참조를 추가하려고하면 프로젝트 참조를이 솔루션의 다른 Silverlight 프로젝트에만 추가 할 수 있다고 나와 있습니다. UI 레이어의 참조를 DTO 라이브러리에 추가하려고 할 때 발생합니다. – TommyK
@TommyK - Silverlight를 사용하고 있으므로 DTO는 Silverlight 클래스 라이브러리 여야합니다. 그러면 Silverlight에서 지원하지 않는 코드가없는 한 서버 및 클라이언트 측에서 하나의 .cs 파일로 연결할 수 있습니다. 몇 가지 아이디어를 얻으려면 http://www.netfxharmonics.com/2008/12/Reusing-NET-Assemblies-in-Silverlight를보십시오. – DaveB