none
How can I mark an EntityRef property as a [DataMember] for WCF serialization? RRS feed

  • Question

  • I have a LINQ to SQL generated class:
    [Table(Name="dbo.USER_ROLES")]
    [DataContract()]
    public partial class USER_ROLE : INotifyPropertyChanging, INotifyPropertyChanged
    {		
    	private short _USER_ID;
    		
    	private short _ROLE_ID;
    		
    	private EntityRef<ROLE> _ROLE;
    		
    	private EntityRef<USER> _USER;
    		
    	[Column(Storage="_USER_ID", DbType="SmallInt NOT NULL", IsPrimaryKey=true)]
    	[DataMember(Order=1)]
    	public short USER_ID
    	{ ..... }
    		
    	[Column(Storage="_ROLE_ID", DbType="SmallInt NOT NULL", IsPrimaryKey=true)]
    	[DataMember(Order=2)]
    	public short ROLE_ID
    	{ ..... }
    		
    	[Association(Name="ROLE_USER_ROLE", Storage="_ROLE", ThisKey="ROLE_ID", OtherKey="ROLE_ID", IsForeignKey=true)]
    	public ROLE ROLE
    	{ ..... }
    		
    	[Association(Name="USER_USER_ROLE", Storage="_USER", ThisKey="USER_ID", OtherKey="USER_ID", IsForeignKey=true)]
    	public USER USER
    	{ ....... }
    		
    }
    

    I am using WCF to deliver to the client application, which works fine. However, because the ROLE and USER properties are not marked as [DataMember], the client side USER_ROLE class, auto-generated by WCF, does not contain the USER and ROLE properties.

    How can I configure the LINQ class to mark these properties as [DataMember]?
    Friday, January 22, 2010 1:49 PM

Answers