Mapping serivce method fields to multiple properties

  • 2 March 2009
  • 2 replies
  • 0 views

Badge +2

Hi,


 Is it possible to map a service method field to more than one property in a method:


E.G. I would like to have the value of one property value returned from a service method to be mapped to 2 different fields as like the following SQL Statement:


SELECT UserID as [Key], UserName as [Value], UserID as [DisplayColumn1], Email as [DisplayColumn2], CellNo as [DisplayColumn3] FROM Users


SELECT PaymentID as [Key], PaymentNumber as [Value]PaymentNumber as [DisplayColumn1], PaymentValue as [DisplayColumn2], PaymentDate as [DisplayColumn3] FROM Payments


 The reason I ask is that I want a generic details view of various SmartObjects. I tried creating one method which calls the GetList method of the same SmartObject twice but when I run the call to the method I get the following error ("An item with the same key has already been added").


Regards


Mike


2 replies

Badge +8

Looking at your example, all you need to do is return the single field called UserID or PaymentNumber.  Then if you are using the SmartObject data provider you can do exactly what you are inferring in the example SQL code you provided.  You do not need to do what you are trying to do in the SmartObject method configuration.


Jason

Badge +2

Hi Jason,


 What I was trying to do was have a genaric ASP lookup page for multiple SmartObjects with hidden Key & Value fields and then some informational fields which could be set in the SmartObject methods. I was hoping to have a straight forward databound grid with only a paramater changing value on the datasource which called a stored proc. I ran into the problem when I wanted to map one field to both the Key/Value fields and and informational field. I was just wondering if it was actually possible to do it with a SmartObject method (I guess not).


 I resorted to using different select commands (similiar to my original example) to map the fields the way I wanted. I used a select command like this:


SELECT {0}.{1} as [__LookupKey], {0}.{2} as [__LookupValue], {0}.{3} as [__DisplayColumn1], {0}.{4} as [__DisplayColumn2], {0}.{5} as [__DisplayColumn3] FROM {0}


All I had to fo was format the command along the lines of  


SelectCommand = String.Format(sql, "[Customer.GetList]","[CustomerID]","[CustomerName]","[CustomerName]","[ContactName]","[Email]","[Telephone]");


  Thanks

Reply