使用带有WCF的Entity

使用带有WCF的Entity

本文介绍了使用带有WCF的Entity Framework将引用的值插入表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两张桌子

city详情及酒店详情在城市房价详情为$
列是CityID和CityName

酒店详细信息中的列是HotelId ,酒店名称,开始日期和城市ID(City Details表中CityID的FK)

我在datacontract中定义了这些

I have two tables
city Details and Hotel Details
columns in City Details are CityID and CityName
Columns in Hotel Details are HotelId, Hotel name, startdate and City ID (FK of CityID in City Details table)
I have defined these in the datacontract as below


public class Hotel
 {
  [DataContract]
  public class HotelDetails
  {
   private int _HotelID;
   private string _HotelName;
   private int _TotalRooms;
   private DateTime _StartDate;
   private string _City;

   [DataMember]
   public int HotelID
   {
    get { return _HotelID; }
    set { _HotelID = value; }
   }

   [DataMember]
   public string HotelName
   {
    get { return _HotelName; }
    set { _HotelName = value; }
   }

   [DataMember]
   public int TotalRooms
   {
    get { return _TotalRooms; }
    set { _TotalRooms = value; }
   }

   [DataMember]
   public DateTime StartDate
   {
    get { return _StartDate; }
    set { _StartDate = value; }
   }

   [DataMember]
   public string City
   {
    get { return _City; }
    set { _City = value; }
   }

  }

 }

 public class Cities
 {
  [DataContract]
  public class CitiesDetails
  {
   private int _CityID;
   private string _CityName;

   [DataMember]
   public int CityID
   {
    get { return _CityID; }
    set { _CityID = value; }
   }

   [DataMember]
   public string CityName
   {
    get { return _CityName; }
    set { _CityName = value; }
   }
  }
 }

推荐答案

您在此处发布的代码看起来像您要发送回服务器进行处理和更新的DTO?我怀疑您的代码错误在sav​​eRecordHotel中,您可以发布吗?这是执行实际保存的代码,因此这是一个有趣的

The code you have posted here looks like a DTO that you are sending back to the server for handling and updating? I suspect that the error of your code is in saveRecordHotel, could you post that? This is the code that does the actual saving, so that's the one interesting here.

 


这篇关于使用带有WCF的Entity Framework将引用的值插入表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 03:00