Scenario: I need to create a report in which the data does not map well to existing entities.
Solution: My solution is to write a raw method and have it return a DataSet.
Assumption: If I write a raw method in which none of the fields in the query match the properties of the entity, it will still work as long as I specify a return type of System.Data.DataSet.
Questions:
- Is my assumption correct?
- Using the Modeler, other than specifying the Return Type Name as System.Data.DataSet is there anything else I'm suppose to do?
- Do you see any errors in my code. I did a build on the model it generated the code without error. But when I build/compile the BOM, that when I get errors. I had to enter my code/xml as a code snippet because stackexchange is being quirky and was the only way it would display. Run code snipper button won't do anything.
<cf:entity name="Test1" namespace="Amikids.TimeTracking" categoryPath="/Amikids.TimeTracking">
<cf:property name="Id" key="true" />
<cf:property name="Name" />
<cf:instance>
<cf:instanceValue name="Id">bda62961-eef9-48bd-977e-00732ce36c66</cf:instanceValue>
<cf:instanceValue name="Name">Mike</cf:instanceValue>
</cf:instance>
<cf:instance>
<cf:instanceValue name="Id">3378eddd-cd46-40e3-b5c5-eecaa1477229</cf:instanceValue>
<cf:instanceValue name="Name">Joe</cf:instanceValue>
</cf:instance>
<cf:method name="LoadReport" body="LOAD() ORDER BY Name" returnTypeName="System.Data.DataSet" />
</cf:entity>
Errors:
Error 26 'System.Data.DataSet' does not contain a definition for 'LoadReport' and no extension method 'LoadReport' accepting a first argument of type 'System.Data.DataSet' could be found (are you missing a using directive or an assembly reference?)
Error 25 'System.Data.DataSet' does not contain a definition for 'PageDataLoadReport' C:\Projects2\Amikids.TimeTracking\Amikids.TimeTracking\Test1Collection.cs
Error 27 'System.Data.DataSet' does not contain a definition for 'PageLoadReport' C:\Projects2\Amikids.TimeTracking\Amikids.TimeTracking\Test1Collection.cs
Additional Comments:
I looked at the article https://blog.codefluententities.com/2011/06/22/dataset-support-in-codefluent-entities/ but I think it's outdated or incomplete. Below is the syntax from the article and it's very different from what the modeler creates. I attempted to use the same syntax as the article but Codefluent Entities automatically re-wrote in a different way that also didn't work.The method also doesn't indicate if its using SQL Server, Oracle etc so I think some things are missing from the sample.
<cf:method name="LoadAllCities" body="raw" returnTypeName="System.Data.DataSet">
SELECT $Address::City$ FROM $Address$
</cf:method>