This is a migrated thread and some comments may be shown as answers.

How can we specify the string length in OpenAccess

1 Answer 132 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Håkan
Top achievements
Rank 1
Håkan asked on 05 Aug 2012, 01:42 PM

Hi All,

How can we specify the string length in OpenAccess.

We create a class  as follows

using System.ComponentModel.DataAnnotations;

namespace Crowdlogistics.Party.Domain

{

    [Serializable]

    public class PartyRelationShipType

    {

        public int RelationshipTypeID { get; set; }

        public string RelationshipType { get; set; }

        [StringLength(12)]

        public string CreatedBy { get; set; }

        public DateTime CreatedOn { get; set; }

        [StringLength(12)]

        public string UpdatedBy { get; set; }

        public DateTime UpdatedOn { get; set; }

    }

}

But string length was not taken in DB. How can we do this.

Development Team.

1 Answer, 1 is accepted

Sort by
0
Viktor Zhivkov
Telerik team
answered on 08 Aug 2012, 02:35 PM
Hello,

You can specify the length of a string property by two ways:
  1. Using Table Editor - provide a value in the numeric up down control for Precision for the target column. You can find more information about Table Editor on this page.
  2. Using Fluent Mapping - setting HasLenght property to the desired value as described in this article.
The data annotation attribute that you are using will not help you achieve your goals in this case. It will add the specified string length in the metadata associated with a WCF Plain or Data Service, but not with the OpenAccess data model.

If you have any additional questions do not hesitate to contacts us again.

All the best,
Viktor Zhivkov
the Telerik team
OpenAccess ORM Q2'12 Now Available! Get your hands on all the new stuff.
Tags
Getting Started
Asked by
Håkan
Top achievements
Rank 1
Answers by
Viktor Zhivkov
Telerik team
Share this question
or