locked
Pass new property like (string myusername) from controller page to Business proj(Repositories) by Metadata. New prop is not in EF model RRS feed

  • Question

  • User-1347841061 posted

    public partial class Buyer
    {
        [DataMember]
        public int Id { get; set; }

        [DataMember] 
        public short BuyerMethod { get; set; }

        [DataMember]
        public string BuyerContent { get; set; }

        [DataMember]
        public short BuyerFormat { get; set; }
      
    }

    This is my Metadata partial class in edmx project folder (another layer)

    [MetadataType(typeof(BuyerDeliveryMetadata))]
    [DataServiceKey("Id")]
    public partial class Buyer
    {

    }

    This is in web app project (Metadata foleder)
    [MetadataType(typeof(BuyerDeliveryMetadata))]
    public partial class Buyer
    {

    }

    This is in Controller page
    this.ClientRepositories.BackOfficeData.UpdateObject(buyer);

    I want to pass my string usesrname value from controller page to Business proj(Repositories) by by buyer object which is not in EF.

    thanks

    Thursday, November 20, 2014 10:57 AM

Answers

  • User-434868552 posted

    @hmsarab

    void Main()
    {
       BackOfficeData.UpdateObject("Jane Doe"); 
       BackOfficeData.UpdateObject("John Doe", "hmsarab"); 
    }
    
    public class BackOfficeData
    {
        public static void UpdateObject(String buyer)            // overload 1 of 2       
        {
            Console.WriteLine ("overload 1 Buyer:  {0}", buyer);
        }
        
        public static void UpdateObject(String buyer, String myUserName) // overload 2 of 2
        {
            Console.WriteLine ("overload 2 Buyer:  {0}", buyer);
            Console.WriteLine ("overload 2 User:   {0}", myUserName);
        }
    }

    output:

    overload 1 Buyer:  Jane Doe
    overload 2 Buyer:  John Doe
    overload 2 User:   hmsarab

    Reference:

    http://msdn.microsoft.com/en-us/library/ms229029(v=vs.110).aspx "Member Overloading"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 24, 2014 12:08 PM

All replies

  • User-434868552 posted

    @hmsarab   welcome to forums.asp.net

    Just an idea, create an overload, something like this:

    .UpdateObject(buyer, myusername)

    Thursday, November 20, 2014 3:45 PM
  • User-1347841061 posted

    Thank you for your response.

    I appreciate you if you write me how can to write the code Or pass me useful link to help.

    Thanks again. 

    Monday, November 24, 2014 6:28 AM
  • User-434868552 posted

    @hmsarab

    void Main()
    {
       BackOfficeData.UpdateObject("Jane Doe"); 
       BackOfficeData.UpdateObject("John Doe", "hmsarab"); 
    }
    
    public class BackOfficeData
    {
        public static void UpdateObject(String buyer)            // overload 1 of 2       
        {
            Console.WriteLine ("overload 1 Buyer:  {0}", buyer);
        }
        
        public static void UpdateObject(String buyer, String myUserName) // overload 2 of 2
        {
            Console.WriteLine ("overload 2 Buyer:  {0}", buyer);
            Console.WriteLine ("overload 2 User:   {0}", myUserName);
        }
    }

    output:

    overload 1 Buyer:  Jane Doe
    overload 2 Buyer:  John Doe
    overload 2 User:   hmsarab

    Reference:

    http://msdn.microsoft.com/en-us/library/ms229029(v=vs.110).aspx "Member Overloading"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 24, 2014 12:08 PM
  • User-1347841061 posted

    It was great.

    Thanks

    Friday, December 5, 2014 12:52 PM