On Fri, 2010-01-15 at 21:08 -0800, Toby Johnson wrote:
> On Jan 10, 4:37 pm, Toby Johnson <[email protected]> wrote:
> > I am using DbMetal with the --sprocs option to generate methods from
> > Stored Procedures but I see that this returns DataSets and not Linq
> > objects.
...
> I've hacked together a Perl script that reads in a list of Sproc-to-
> type mappings, then goes through the generated file and replaces the
> sproc methods with a call to this method, using the appropriate return
> type and parameters.
> 
> So, if I actually modified the DbLinq sources to do this instead (say,
> add a command-line parameter to accept a sproc-to-type mapping file
> name, then use that to generate the sproc methods), would such a patch
> be considered for inclusion?

No.  The correct fix is to drop the DataSet and generate a *correct*
binding for the stored procedures.

For example, .NET's sqlmetal generates the following method for a stored
procedure:

        [Function(Name="dbo.CustOrderHist")]
        public ISingleResult<CustOrderHistResult> 
CustOrderHist([Parameter(Name="CustomerID", DbType="NChar(5)")] string 
customerID)
        {
                IExecuteResult result = this.ExecuteMethodCall(this, 
((MethodInfo)(MethodInfo.GetCurrentMethod())), customerID);
                return 
((ISingleResult<CustOrderHistResult>)(result.ReturnValue));
        }
        
        // ...
        public partial class CustOrderHistResult
        {
                
                private string _ProductName;
                
                private System.Nullable<int> _Total;
                
                public CustOrderHistResult()
                {
                }
                
                [Column(Storage="_ProductName", DbType="NVarChar(40)")]
                public string ProductName
                {
                        get
                        {
                                return this._ProductName;
                        }
                        set
                        {
                                if ((this._ProductName != value))
                                {
                                        this._ProductName = value;
                                }
                        }
                }
                
                [Column(Storage="_Total", DbType="Int")]
                public System.Nullable<int> Total
                {
                        get
                        {
                                return this._Total;
                        }
                        set
                        {
                                if ((this._Total != value))
                                {
                                        this._Total = value;
                                }
                        }
                }
        }
        
DbMetal should do likewise, and generate a strongly typed return type
for stored procedures, NOT return DataSets.  This is the correct fix.

I'd *love* a patch that did *that*. :-)

Thanks,
 - Jon


-- 
You received this message because you are subscribed to the Google Groups 
"DbLinq" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/dblinq?hl=en.


Reply via email to