Ticket T528558
Visible to All Users

[DbType("smallint(2) NOT")] // not working.

created 8 years ago (modified 8 years ago)

[DbType("smallint(2)")] is working, but I need [DbType("smallint(2) NOT")]

[DbType("smallint(2) NOT")] ==> I test for any collection, it does not work.
                                                         in MsSql DB (version 2014) , this column Allow Nulls is checked (true)
Example 1:

C#
private tblSubeler fSubeKodu; [DbType("smallint(2) NOT")] // not working. [Index(0)] [Indexed(@"FisFatNo", Name = @"tblFisSiparis_IND_1"), Browsable(false)] [Association(@"tblFisSiparis-tblSubeler")] public tblSubeler SubeKodu { get { return fSubeKodu; } set { SetPropertyValue<tblSubeler>("SubeKodu", ref fSubeKodu, value); } }

Example 2:

C#
private tblCariSabit fCariKodu; [DbType("nvarchar(15) NOT")] // not working. [Persistent("CariKodu"), Size(15), Indexed(Name = @"CariKodu_UNIQUE")] [RuleRequiredField("tblCariSabit.CariKodu", DefaultContexts.Save, "Cari Kodu boş geçilemez.")] public tblCariSabit CariKodu { get { return fCariKodu; } set { SetPropertyValue<tblCariSabit>("CariKodu", ref fCariKodu, value); } }

Answers approved by DevExpress Support

created 8 years ago (modified 8 years ago)

Hello Cengiz,

The DbType attribute does not have an effect on reference properties, since their type is set based on the PK column type of the related table. So, you need to apply this attribute to the key property of the tblCariSabit table (see Basics of Creating Persistent Objects for Existing Data Tables). In addition, note that this attribute has an effect only if the database column for this property is not created yet.
In addition, note that the smallint(2) type is invalid for MS SQL - see Cannot specify a column width on data type int.

    Show previous comments (3)
    Anatol (DevExpress) 8 years ago

      Since the DbType attribute does not have effect on reference properties, you can add the NOT NULL constraint by executing a direct SQL query after XPO creates database tables - see Direct SQL Queries.
      Alternatively, create the XPO Data Provider's descendant and override its GetSqlCreateColumnFullAttributes method to replace NULL with NOT NULL in the generated SQL text. Refer to the How to create a custom XPO connection provider and then use it in an XAF application article for additional information.

        Apparently, there's going to be a lot of work for me. Thank you very much.

        Anatol (DevExpress) 8 years ago

          You are welcome! Please do not hesitate to contact us if you encounter any difficulty.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.