This issue has been studied in the past few days.
I have not found a solution for searching the Internet. I only need to execute the stored procedure in the nhib.pdf.
One way to operate nhib.pdf in it
So I wrote the following class.
Of course, the test can only be passed, and there may be many problems to be solved one by one.
Namespace chalumna. castleext
{
Using Castle. activerecord;
Using Castle. activerecord. Framework;
Using Castle. activerecord. Framework. config;
Using system;
Using nhib.pdf;
Using nhib.pdf. cfg;
Using nhib.pdf. expression;
Using system. Collections. Generic;
Using system. text;
Using system. Data;
Public class Execute
{
/** // <Summary>
/// Use the stored procedure to fill the object class, ZOU Jian, 2008 1 24
/// </Summary>
/// <Typeparam name = "T"> entity class </typeparam>
/// <Param name = "spname"> name of the stored procedure </param>
/// <Param name = "IDICT"> parameter dictionary </param>
/// <Returns> one entity class ilist </returns>
Public static ilist <t> getlist <t> (string spname, idictionary <string, Object> IDICT ){
Type type = typeof (t );
// Chsword. dodatabase d = new chsword. dodatabase ();
Stringbuilder sp = new stringbuilder ();
Foreach (string key in IDICT. Keys ){
Sp. appendformat (": {0},", key );
}
If (sp. length! = 0)
Sp. Length --;
String map = string. Format (@ "<SQL-query name = '{0}'>
<Return class = '{1}'/>
Exec {0} {2}
</SQL-query> ",
Spname,
Type. Name,
Sp. tostring ()
);
Execute. createquerymapping (type, MAP); // create an SQL-Query
Isessionfactoryholder holder = activerecordmediator. getsessionfactoryholder ();
Isession session = holder. createsession (type );
IQUERY query = session. getnamedquery (spname );
Foreach (string key in IDICT. Keys ){
Query = query. setparameter (Key, IDICT [Key]);
}
Return query. List <t> ();
}
/** // <Summary>
/// Create an SQL-Query
/// </Summary>
/// <Param name = "type"> type, used as the key </param>
/// <Param name = "XML"> SQL-query node </param>
Public static void createquerymapping (type, string XML ){
Isessionfactoryholder holder = activerecordmediator. getsessionfactoryholder ();
Configuration Config = holder. getconfiguration (holder. getroottype (type ));
// Xml =;
Config. addxmlstring (
String. format ("Configuration. mappingschemaxmlns,
Type. Assembly. fullname,
Type. namespace, // namespace
XML // content is <SQL-query/>
)
);
// Return config. namedsqlqueries. Count. tostring ();
}
}
}
The usage is as follows:
Idictionary <string, Object> P = new dictionary <string, Object> (); // Parameter
P. Add ("userid", 10000); // parameter 1
P. Add ("ID", 17002); // parameter 2
P. Add ("groupid", 51); // parameter 3
Propertybag. Add ("list ",
Chalumna. castleext. Execute. getlist <logtoaccount> (// Execute
"Note_select", P
));
Propertybag. Add is a system dictionary in monorail. The test is normal.
However, the following are not enough (I think)
the parameter cannot be out.
you cannot associate a class with one. You can only create a new class based on fields in the stored procedure, or extend the original entity class.
I cannot think of it. If you are interested, try it on your own.