Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
i'm having a trouble trying to get a property of a model from a sql server database, i have define the property on my model but when i do a linq query it doesn't let me get that property

this is my model:


C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Web.Mvc;

namespace ProgramaAlimenticio.Models
{
    public class RutaMD
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
        public virtual int pk_ruta { get; set; }

        [Display(Name = "Ruta")]
        public virtual string nombre { get; set; }

        [Display(Name = "Proveedor")]
        public virtual Nullable<int> fk_proveedor { get; set; }

        [Display(Name = "Programa")]
        public virtual int fk_programa { get; set; }
    }

    [MetadataType(typeof(RutaMD))]
    public partial class Ruta {  }
}

Hope some one help the property that is not available is the fk_programa

when i do a the next query the peroblem happens


C#
var programas = from r in db.Ruta
               join p in db.Programa on r.fk_programa equals p.pk_programa
               into o
               select o;
Posted
Updated 13-Nov-13 5:17am
v2
Comments
Jameel VM 13-Nov-13 11:19am    
your question is not clear. can you elaborate? did you got the query results?
Erick Garcia 13-Nov-13 11:23am    
it throws an exception i even doesn't have neither clear what is happening, what i'm trying to do is a join form two tables, those are db,Ruta and db.Programa but it seems like the field fk_programa on the model Ruta doesn't exits =( and thats the problem
Jameel VM 13-Nov-13 11:36am    
what is the exception?

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