Bir Varlık Çerçevesi (v5.0) veritabanı ilk yaklaşımını kullanıyorum, doğrulama için veri ek açıklamalarını kullanmanın en iyi yolu nedir?Entity Framework 5.0 ile Veri Ek Açıklamaları (önce veritabanı)
Bu Varlık Framework benim kısmi sınıf oluşturulur: 'PayrollMarkup_State.cs'
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System.ComponentModel.DataAnnotations;
namespace ACore
{
using System;
using System.Collections.Generic;
public partial class PayrollMarkup_State
{
public string State { get; set; }
public Nullable<float> MaintenancePercentage { get; set; }
public Nullable<float> OfficePercentage { get; set; }
}
}
:
varlık Framework dosyayı oluşturan
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System.ComponentModel.DataAnnotations;
namespace ACore
{
using System;
using System.Collections.Generic;
public partial class PayrollMarkup_State
{
[UIHint("StatesEditor")] // <-- I added this line but it will be overwritten
public string State { get; set; }
public Nullable<float> MaintenancePercentage { get; set; }
public Nullable<float> OfficePercentage { get; set; }
}
}
hiçbir başarı ile denedim ....
Bu dosyayı farklı bir dizinde oluşturdum: 'PayrollMarkup_state.cs'
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
namespace ACore.Models
{
[MetadataType(typeof(PayrollMarkupMetadata))]
public partial class PayrollMarkup_State
{
}
public class PayrollMarkupMetadata
{
[UIHint("StatesEditor")]
public string State; // Has to have the same type and name as your model
}
}
Bildirirseniz bu gerçekten işe yarar meta veri sınıfınızda bir mülk yerine bir alan mı? – JYL
@JYL evet, bir alan ya da mülk olup olmadığına bakmaz, sadece bir dolaylı mekanizmadır. "Bu şeyi başka bir sınıfta bu tür ve adla bulun ve bu öznitelikleri buna uygulayın." – GalacticCowboy
Ok teşekkürler! +1. – JYL