Questions tagged [executestorequery]

14 questions
11
votes
1 answer

Entity Framework - CreateQuery VS ExecuteFunction VS ExecuteStoreQuery VS ExecuteStoreCommand

What are the differences between following- CreateQuery()  ExecuteFunction(), ExecuteStoreQuery() and ExecuteStoreCommand() As per my knowledge CreateQuery is used for Entity SQL & rest of the methods are used for sql function or stored procedure…
paul sim
  • 463
  • 2
  • 10
  • 23
6
votes
2 answers

The data reader has more than one field. Multiple fields are not valid for EDM primitive types

I am trying to delete multiple rows from the table using linq's ExecuteStoreQuery method like this string query = "delete from IMPORTStatistics where districtid='" + districtId + "'"; db.ExecuteStoreQuery(query); but it is throwing this…
Pawan Nogariya
  • 8,330
  • 12
  • 52
  • 105
5
votes
1 answer

ExecuteStoreQuery with TVP parameters

I have a stored procedure in my database that takes a table value parameter, a list of IdTable objects which contain a single integer Id column. I have an entity model for the database and want to do the following... ProjectEntities projectEntities…
Colin Desmond
  • 4,824
  • 4
  • 46
  • 67
5
votes
1 answer

What is difference between ExecuteStoreQuery and ExecuteStoreCommand

In entityframework we can use ExecuteStoreQuery or ExecuteStoreCommand to execute sql queries. So what is difference between them(which scenario it is different)? Thank you.
Manas Kumar
  • 2,411
  • 3
  • 16
  • 23
2
votes
1 answer

ROW_NUMBER() Over workaround using ExecuteStoreQuery Cryptic Result Error

I am using EF4.0 to do in my mind a very basic query. I have confirmed that all columns reference in my tables are Int (we don't use bigint nor smallint) so I ruled that out. I have tried changing the types to Int64 which it then complains about…
2
votes
1 answer

How to check for errors in C# using ExecuteStoreQuery executing a stored procedure?

I have a stored procedure that I am calling using the ObjectContext ExecuteStoreQuery method so that I can get the result set that the stored procedure returns. I have it inside of a try/catch block, however even though the stored procedure returns…
user281677
  • 249
  • 1
  • 2
  • 9
2
votes
0 answers

How to execute procedure returning dynamic column using Entity Framework?

I am executing a procedure using following code. SqlParameter LTParam = new SqlParameter("@LearningTrackID",learningTrackID); dynamic LTReport = objectContext.ExecuteStoreQuery( "exec usp_LearningTrackReport…
1
vote
2 answers

Entity Framework ExecuteStoreQuery fails on deployed systems

Ok, a bit stumped here, and instead of banging my head any more on this, I thought I'd toss this out to all the bright people here. I'm using Entity Framework and c# for a WinApp solution, and the core of the problem is that the darned thing runs…
1
vote
1 answer

How to check if ObjectResult collection was empty?

I have this piece of code which check the last customer_id from the db. ObjectResult last_customer_id_collection = MainForm.eggsContext.ExecuteStoreQuery("select MAX(customer_id) from customers"); Then I get the next id required like…
BornToCode
  • 9,495
  • 9
  • 66
  • 83
0
votes
1 answer

Requery subform

I want to requery my sub form by converting my SQL code into String and then perform requery function. The problem is, I cannot convert the SQL code below into Proper string that the .RecordSource can evaluate. Here is my original SQL code: SELECT…
Jason Chan
  • 45
  • 10
0
votes
1 answer

ExecuteStoreQuery not working with DateTime setter

I'm having trouble getting ExecuteStoreQuery to work correctly with my custom class which has a DateTime member. It gets the default DateTime value (1/1/0001 12:00:00 AM) instead of what is in the database. List results =…
0
votes
1 answer

Fetch rows from database using ExecuteStoreQuery, without knowing the number of columns in the table

I'm trying to do some manual SQL queries against my SQLite database using the ExecuteStoreQuery method on my ObjectContext. The catch is that I don't always know how many columns are in the table that I'm querying. Ideally, I would like each fetched…
Pieter Müller
  • 4,573
  • 6
  • 38
  • 54
0
votes
1 answer

ExecuteStoreQuery and "WHERE IN ({0})

I got the following code: string query = "select * from dbo.Personnel where PersonnelId in ({0})"; string param = "1, 2"; var test = model.ExecuteStoreQuery(query, param).ToList(); I get the following error: "Conversion failed when…
0
votes
1 answer

Do I need to use parametrized queries when calling ExectureStoreQuery to avoid SQL Injections?

I'm wondering if I need to use parameterized queries when executing sql from ExecuteStoredProcedure in order to prevent SQL Injection attacks? According to this MSDN link, I should be using parameters. According to this other MSDN link, a sql string…
chris
  • 36,094
  • 53
  • 157
  • 237