WCF Rest and Code Firstについて何か分かりません。私はテーブルの患者だけの場合。私は問題のないすべての患者のリストを持つことができますが、私はユーザテーブルを持っていて、患者テーブルには外部キーがあります。私は患者のリストを持つことはできません。 私は十分にはっきりしていることを願っています。あなたは マイサービス Iservice以下の私のコードWCF Rest Code First feignキーテーブルのリストを返すことができません
namespace HandyifeService
{
[ServiceContract]
public interface IHandyServce
{
[OperationContract]
[WebInvoke(Method = "GET",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "Test")]
List<Patient> GetPatientList();
}
}
サービス
public class HandyService : IHandyServce
{
public List<Patient> GetPatientList()
{
List<Patient> listpatients = (from pat in mobile.Patient select pat).ToList();
return listpatients;
}
}
コードファースト のDataModel
public partial class Model1 : DbContext
{
public Model1()
: base("name=Model1")
{
}
public virtual DbSet<Patient> Patient { get; set; }
public virtual DbSet<Utilisateur> Utilisateur { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Patient>()
.Property(e => e.pat_nom)
.IsUnicode(false);
modelBuilder.Entity<Patient>()
.Property(e => e.pat_prenom)
.IsUnicode(false);
modelBuilder.Entity<Patient>()
.Property(e => e.pat_adresse)
.IsUnicode(false);
modelBuilder.Entity<Patient>()
.Property(e => e.pat_ville)
.IsUnicode(false);
modelBuilder.Entity<Patient>()
.Property(e => e.pat_pays)
.IsUnicode(false);
modelBuilder.Entity<Patient>()
.Property(e => e.pat_Natel)
.IsUnicode(false);
modelBuilder.Entity<Patient>()
.Property(e => e.pat_Teleèhone)
.IsUnicode(false);
modelBuilder.Entity<Patient>()
.Property(e => e.pat_nomMere)
.IsUnicode(false);
modelBuilder.Entity<Patient>()
.Property(e => e.pat_prenomMere)
.IsUnicode(false);
modelBuilder.Entity<Patient>()
.Property(e => e.pat_nomPere)
.IsUnicode(false);
modelBuilder.Entity<Patient>()
.Property(e => e.pat_prenomPere)
.IsUnicode(false);
modelBuilder.Entity<Utilisateur>()
.Property(e => e.uti_titre)
.IsUnicode(false);
modelBuilder.Entity<Utilisateur>()
.Property(e => e.uti_nom)
.IsUnicode(false);
modelBuilder.Entity<Utilisateur>()
.Property(e => e.uti_prenom)
.IsUnicode(false);
modelBuilder.Entity<Utilisateur>()
.Property(e => e.uti_login)
.IsUnicode(false);
modelBuilder.Entity<Utilisateur>()
.Property(e => e.uti_password)
.IsUnicode(false);
modelBuilder.Entity<Utilisateur>()
.HasMany(e => e.Patient)
.WithOptional(e => e.Utilisateur)
.HasForeignKey(e => e.pat_id_utilisateur);
}
}
患者
[Table("Patient")]
public partial class Patient
{
[Key]
public Guid id_patient { get; set; }
[StringLength(255)]
public string pat_nom { get; set; }
[StringLength(255)]
public string pat_prenom { get; set; }
public DateTime? pat_datenaissance { get; set; }
[StringLength(255)]
public string pat_adresse { get; set; }
public int? pat_npa { get; set; }
[StringLength(255)]
public string pat_ville { get; set; }
[StringLength(255)]
public string pat_pays { get; set; }
[StringLength(255)]
public string pat_Natel { get; set; }
[StringLength(255)]
public string pat_Teleèhone { get; set; }
[StringLength(255)]
public string pat_nomMere { get; set; }
[StringLength(255)]
public string pat_prenomMere { get; set; }
[StringLength(255)]
public string pat_nomPere { get; set; }
[StringLength(255)]
public string pat_prenomPere { get; set; }
public DateTime pat_creation { get; set; }
public DateTime pat_update { get; set; }
public Guid? pat_id_cabinet { get; set; }
public Guid? pat_id_utilisateur { get; set; }
public virtual Utilisateur Utilisateur { get; set; }
}
を見つけるだろう
ユーザー
[Table("Utilisateur")]
public partial class Utilisateur
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Utilisateur()
{
Patient = new HashSet<Patient>();
}
[Key]
public Guid id_utilisateur { get; set; }
[StringLength(15)]
public string uti_titre { get; set; }
[StringLength(100)]
public string uti_nom { get; set; }
[StringLength(100)]
public string uti_prenom { get; set; }
[StringLength(50)]
public string uti_login { get; set; }
[StringLength(200)]
public string uti_password { get; set; }
public Guid? uti_Id_cabinet { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<Patient> Patient { get; set; }
}
問題が何であるか教えていただけますか? 事前のおかげで 敬具
エラーが発生しますか?何が問題なのですか? –
私は郵便配達員を使って休憩サービスをテストしています。郵便配達員は私に何の応答も得られなかった。それは私の残りのようなものですサービスは他のテーブルのために答えることができません。リンクテーブルがなければ、動作しています。 – Ludovic