views:

426

answers:

1

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

Situation:

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

Problem:

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..

Problem #2:

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.

Question:
Is it possible to exclusively turn off mapping for this entity prop only for this one sproc?

+1  A: 

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.

Mark Dickinson
Sproc shouldn`t be touched. It has full-text search functionality with rankings, paging etc. That`s why it can`t handle XML data typed columns.This problem took me a awhile but i managed it. I had to create redundant entity with excluded prop and redundant view (at least in l2e conf xml - it can be ignored in database).Read somewhere - it won`t be a problem in next l2e update.
Arnis L.