Formula in NHibernate ing

Source: Internet
Author: User
Tags sql 2008

In the object class ing of nhib.pdf, if the attributes of the object class can be obtained only through SQL calculation, you can use the Formula option.

Nhib.pdf has the following requirements for Formula:

Formula (optional): an SQL expression that defines the value for a computed property. Computed properties do not have a column mapping of their own.

Scenario 1: Map attributes to be calculated

The following Category ing is used as an example:

<?xml version="1.0" encoding="utf-8" ?>

If you want to add the NameAndDesc attribute and connect the CategoryName and Description fields, use Formula to do the following:

<property name="NameAndDesc" formula="[CategoryName] + ' ' + [Description]" type="string" />

Scenario 2: ing complex SQL types

SQL 2008 supports spatial data types geography and geometry. ing spatial data types can be solved through the spatial expansion of nhib.pdf, Which is troublesome to operate, if the client does not need a spatial data type or cannot process the spatial data type, you can use Formula for processing. The structure of the example table is defined as follows:

CREATE TABLE SpatialTable (   id int IDENTITY (1,1),   GeogCol1 geography,);

The foring file using Formula is as follows:

<?xml version="1.0" encoding="utf-8" ?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.