using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.SqlClient; using Xtensive.Orm; using Xtensive.Orm.Validation; using EMS.BLL.Model; using EMS.BLL.Administration.Menu; using EMS.BLL.Administration.Interfaces;

namespace EMS.BLL.MasterInfo.Common { [Serializable] [TableMapping(TableMapping.Breed)] [MenuPath("MasterInfo.Common")] [Index("NameEn", Unique = true)] [Index("NameAr", Unique = true)] public class Breed : BusinessEntity, IsLinkable { [Field(Length = LengthMapping.CodeLength)] [NotNullOrEmptyConstraint] [LengthConstraint(Min = 5)] public string Code { get; set; }

    [Field]
    [NotNullOrEmptyConstraint]
    //[LengthConstraint(Min = LengthMapping.MinLength)]
    public string NameEn { get; set; }

    [Field]
    [NotNullOrEmptyConstraint]
    //[LengthConstraint(Min = LengthMapping.MinLength)]
    public string NameAr { get; set; }

    [Field]
    [NotNullOrEmptyConstraint]
    //[LengthConstraint(Min = LengthMapping.MinLength)]
    public string ShortName { get; set; }

    public override string ToString()
    {
        return NameEn;
    }

    public static string GetCode()
    {
        try
        {
            string newCode = "";
            var breed = Query.All<Breed>().OrderByDescending(ar => ar.Id).FirstOrDefault();
            if (breed == null)
                newCode = "B0001";
            else
                newCode = "B" + (int.Parse(breed.Code.Remove(0, 1)) + 1).ToString("0000");
            return newCode;
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
}

}

asked Feb 27 '15 at 05:50

Bhavini's gravatar image

Bhavini
5556

in above code this type of problem is create Error : 'Xtensive.Orm.Validation.NotNullOrEmptyConstraint' is not an attribute class

(Feb 27 '15 at 05:52) Bhavini Bhavini's gravatar image

One Answer:

Hello Bhavini

Our constraints are based on PostSharp aspects. Those aspects are inherited from System.Attribute. Make sure that you add reference to PostSharp library.

answered Mar 06 '15 at 05:01

Alexey%20Kulakov's gravatar image

Alexey Kulakov
68715

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

Subscription:

Once you sign in you will be able to subscribe for any updates here

Tags:

×2

Asked: Feb 27 '15 at 05:50

Seen: 6,190 times

Last updated: Mar 06 '15 at 05:01

powered by OSQA