Monday, 15 March 2010

c# - sql server / entity framework. call store function from .net 3.5 -



c# - sql server / entity framework. call store function from .net 3.5 -

there problem phone call function

var query = _entities.createquery<double?>( string.format("select [dbo].[udf_exchangecurrencyratesgetvalue] ({0},{1},{2},{3})", "'bid'", activescenario.scenario_id, product.id, pair.instr_id)); var bidvalue = query.execute(mergeoption.overwritechanges).getenumerator().current;

activescenario.scenario_id, product.id, pair.instr_id - integer variables.

when query.execute executed, fires exception:

invalid query syntax., near line 2, column 0.

that query runs on .net 4:

var bidvalue =dataadapter.moduleentities.executestorequery<double?>(string.format("select [dbo].[udf_exchangecurrencyratesgetvalue] ({0},{1},{2},{3})", "'bid'", ratesscenario.scenario_id, product.id, pair.instr_id)).first();

does know how run code on .net 3.5?

if want phone call table-valued function in ms sql via entity framework; can utilize this:

var retval = new list<myclass>(); retval = db.database.sqlquery<myclass>(string.format(@"select * dbo.mydatabasefunction({0})", id)).tolist<myclass>();

we have map type tolist<> method , myclass must include columns homecoming function.

c# entity-framework-4

No comments:

Post a Comment