47543

L2Entities, stored procedure and mapping

Question:

Finally checked out L2E framework and ran into problems almost instantly.<br /> Yeah, i know... i should read some books before.

<strong>Situation:</strong>

entity with props -> id and name.<br /> entity is mapped to table, which has id and name columns.<br /> sproc, which returns ONLY id column.

<strong>Problem:</strong>

ObjectResult<MyProp> result = _container.MyStoredProcedure(uberParameter);

Calling this will cause an error

[guilty method goes here] threw exception: System.Data.EntityCommandExecutionException: The data reader is incompatible with the specified 'DataBase.MyPropTableObject'. A member of the type, 'name', does not have a corresponding column in the data reader with the same name..

<strong>Problem #2:</strong>

Can`t "just return" that field, cause that column has XML data type, but sproc uses fancy select statements, which causes:

Msg 421, Level 16, State 1, Line 1 The xml data type cannot be selected as DISTINCT because it is not comparable.

<strong>Question:</strong><br /> Is it possible to exclusively turn off mapping for this entity prop only for this one sproc?

Answer1:

Problem 1 is due to the proc not having the columns to populate the entity. You don't really need the proc if you have mapped the table, just select the field you want from it using linq

var result = MyEntities.EntityIMapped.First(r => r.id = uberParameter).Name;

Would give you the value from the Name column of the table for the given id. You don't need to use a stored proc for this.

Problem 2 sounds like it is in the proc, I would think that distinct on an xml data column would give a lot of results, but I'm only guessing as I don't know your solution.

This is not a direct answer for your question but, hopefully it will point you in the right direction.

Recommend

  • Cannot be used as type parameter 'TElement' in the generic type or method
  • How do I log out the Acumatica Web Api user?
  • Send parameter to ViewModel through IDialogService when open new window
  • Function import from SQL Server to Entity Framework runtime exception
  • MEF 'The export is not assignable to type' error
  • Calling a stored procedure results in an incorrectly empty DataTable
  • Is this a proper use of DTO?
  • Getting 403 error when trying to retrieve an Azure blob on Web API request
  • Using Entity Framework, should I use RETURN or SELECT in my stored procedures?
  • create new property in new object from linq
  • python: subprocess calling a script which runs a background process hanging
  • Castle Windsor & Command Pattern
  • init_seg and warning C4073 from library code?
  • iOS Localization Doesn't Work with More Than 63 Files
  • why calling cd shell command through system() or execvp() from a child process won't work?
  • QLineEdit password safety
  • Running a C# exe file
  • Join two tables and save into third-sql
  • How to model a transition system with SPIN
  • Websockets service method fails during R startup
  • ORA-29908: missing primary invocation for ancillary operator
  • Alternatives to the OPTIONAL fallback SPARQL pattern?
  • How to get next/previous record number?
  • Why winpcap requires both .lib and .dll to run?
  • Apache 2.4 - remove | delete | uninstall
  • Is there a mandatory requirement to switch app.yaml?
  • Proper way to use connect-multiparty with express.js?
  • Hits per day in Google Big Query
  • Trying to get generic when generic is not available
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • embed rChart in Markdown
  • How to get Windows thread pool to call class member function?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Linking SubReports Without LinkChild/LinkMaster
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • Converting MP3 duration time
  • java string with new operator and a literal