Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi

01. i have create an sql function in my database that take to Date params and get data from 5 tables

02. after that add it to project as entity framework from database and the code generated is:

C#
[DbFunction("Dr_EmploEntities", "SelectEmployee")]
public virtual IQueryable<SelectEmployee_Result> SelectEmployee(Nullable<DateTime> frm_date, Nullable<DateTime> to_date)
{
    var frm_dateParameter = frm_date.HasValue ?
        new ObjectParameter("frm_date", frm_date) :
        new ObjectParameter("frm_date", typeof(DateTime));

    var to_dateParameter = to_date.HasValue ?
        new ObjectParameter("to_date", to_date) :
        new ObjectParameter("to_date", typeof(DateTime));

    return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<SelectEmployee_Result>("[Dr_EmploEntities].[SelectEmployee](@frm_date, @to_date)", frm_dateParameter, to_dateParameter);
}

public DbSet<SelectEmployee_Result> SelectEmployee_Result { get; set; }


03. after that i have create an controller for SelectEmployee_Result

04. after that i run my project and got err in Index View:

HTML
The type 'SelectEmployee_Result' is mapped as a complex type. The Set method, DbSet objects, and DbEntityEntry objects can only be used with entity types, not complex types.


05. and i make breakpoint and see that SelectEmployee_Result has no data so i change the Index Code in controller and fill SelectEmployee with params and get data.

06. after that index view was working and i can view data , but i got the same err message when in try to open details view

so how can i fill SelectEmployee_Result from the beginning with data between two dates to let me use it in all views ?

all what i need here is view data i got i edit before saving it in database Like using DataTable but i need to do that from Entity with sql function


and what is difference between "SelectEmployee" that is my function name and that is need two params and SelectEmployee_Result?
Posted
Updated 6-Feb-15 10:09am
v8
Comments
/\jmot 6-Feb-15 16:03pm    
Remove all code and try to describe with a simple and short description, it'll be very helpful to everyone including you.
Ahmed Amin 6-Feb-15 16:09pm    
i have remove some codes

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900