views:

57

answers:

0

i use a nhibernate with ria services and i test my Domain classes in server and it works but when i want to use ria service in silverlight when i want to get a entityset like thise it give me that entityset is empty:

mainpage.xaml.cs:

    public MainPage()
    {
        InitializeComponent();

        AppointmentDomainContext context = new AppointmentDomainContext(
       new Uri("http://localhost:61575/services/AppointmentService.svc", UriKind.Absolute));

        scheduler.AppointmentsSource = new SessionAppointmentCollection(scheduler, context.Appointments);

        context.Load(context.GetAppointmentsQuery());


    }

class domain Service AppointmentDomainService.cs

[EnableClientAccess()] public class AppointmentDomainService : NHibernateDomainService {

      public AppointmentDomainService()
            : base()

            {


        }


        public IQueryable<Appointment> GetAppointments()
        {
            return Session.Linq<Appointment>();

        }
        public IQueryable<Appointment> GetByBeginDate(DateTime begin)
        {
            return Session.CreateQuery(
                 @"select * 
 from Appointment emp
 where emp.Start=" + begin + "")
                 .SetResultTransformer(new AliasToBeanResultTransformer(typeof(Appointment)))
                 .List<Appointment>()
                 .AsQueryable();

        }

        public Appointment GetAppointment(int appointmentID)
        {
            var query = from appointment in Session.Linq<Appointment>()
                        where appointment.appointmentCode == appointmentID
                        select appointment;
            return query.First<Appointment>();

            //return GetAppointments()
            //           .Where(emp => emp.appointmentCode == appointmentID)
            //           .First<Appointment>();
        }

        public void InsertAppointment(Appointment appointment)
        {
            Session.               
                Save(appointment);
        }

        public void UpdateAppointment(Appointment currentAppointment)
        {

            Session.Update(currentAppointment);
        }

        public void DeleteAppointment(Appointment currentAppointment)
        {

            Session.Delete(currentAppointment);
        }


}