I'm building a web API in SnapDevelop using SQLModelMapper and ODBC, and this is all new to me so far. I have converted a PowerBuilder datawindow to the following (omitted Usings):
namespace MyApp.Models
{
[DataWindow("d_prt", DwStyle.Default)]
[Table("part")]
#region DwSelectAttribute
[DwSelect("select \r\n "
+"@(_COLUMNS_PLACEHOLDER_) \r\n "
+"from \r\n "
+"part p \r\n "
+"where \r\n "
+"p.prt_id=:a_prt_id")]
#endregion
[DwParameter("a_prt_id", typeof(double?))]
[DwKeyModificationStrategy(UpdateSqlStrategy.DeleteThenInsert)]
[UpdateWhereStrategy(UpdateWhereStrategy.KeyAndConcurrencyCheckColumns)]
public class D_Prt
{
[Key]
[Identity]
[DwColumn("p", "prt_id")]
public int Prt_Id { get; set; }
[ConcurrencyCheck]
[DwColumn("p", "prt_cd")]
public string Prt_Cd { get; set; }
[ConcurrencyCheck]
[DwColumn("p", "prt_nm")]
public string Prt_Nm { get; set; }
}
}
My Service class contains the following line which throws an error:
D_Prt d_prt = _dataContext.SqlModelMapper.Load<D_Prt>(prt_id).FirstOrDefault();
The error is:
OdbcException: ERROR [42S02] [SAP][ODBC Driver][SQL Anywhere]Correlation name 'p' not found
The correlation name is defined in the DwSelect attribute value, above. Is SQLModelMapper modifying my Select statement? If so, how can I see what it modifies it to? How can I get around this problem?
Thanks!
{"d_Prt":{"prt_Id":1,"prt_Cd":"Light-S1","prt_Nm":"Strobe Light 150W"},"d_Prt_Inv_Lst":[{"prt_Id":1,"prt_Loc_Id":46,"prt_Loc_Abs_Nm_Shr":"\\SR2\\A3\\B30","prt_Inv_Onhnd":11.0000}]}
You will notice this is a single master object followed by a list of child objects. I plan to display this master/child relationship on a Xamarin page.
Considering I want one Web API call to return compound objects, and further considering that I want my web API to perform most, if not all, data updates via stored procedure calls, do you maintain your recommendation that I use the .NET Datastore?
Yes, it is recommended to create the .NET DataStores because you can maintain them more easily with the visual tools (DataWindow painter). SqlModelMapper does not provide these tools, therefore, you can take advantage of so many productivity enhancements provided through the .NET DataStore.
Now, following are some examples you may refer to for both .NET DataStore and SqlModelMapper:
https://github.com/Appeon/.NET-DataStore-Example
https://github.com/Appeon/SnapObjects-Example
Regards,