среда, 2 апреля 2014 г.

Nullable

VS 2013 Web API Add Controller Dialogs - How to add Model and Context from Referenced Library?

Copy from Here

http://stackoverflow.com/questions/20976962/vs-2013-web-api-add-controller-dialogs-how-to-add-model-and-context-from-refer


Adding a controller in a Web API project works very well - only if your models and EF data context are in the same assembly as the project itself - i.e., located in the project's Models folder.
I created all the POCOs and EF data context in a separate library project, created the library, and referenced it from the Web API project. Unfortunately, the dialogs can only see models and data context whose .cs files reside in the project.
I've looked at similar questions and somehow, other people's add controller dialogs list their models and data contexts from external (referenced) libraries (then they have a different problem, which my problem isn't getting to (yet)).
Is there such a setting (in the IDE or web.config) that I need to specify so that these add controller dialogs will see my library's classes?
share|improve this question
add comment
So far, I've come up with a "dirty" workaround, which I'm not very satisfied, though it works:
  1. Create a dummy class under /Models with arbitrary properties – but one of them has to be int Id.
  2. Go through the add controller dialogs and choose the dummy model.
  3. If you haven’t created a data context, click on New data context. Beware that the dialog will auto-generate the full qualified namespace path of the data context, and that the context name contains a space. Remove it. Click add.
  4. Open the auto-generated controller .cs file.
  5. Reference your library in this .cs file that contains the model and the context.
  6. Find and replace all instances of the dummy class with the actual model’s class name you need. Be careful of plurals. String-replace plurals first, then singular after.
  7. Change the dummy context class to the correct data context class.

понедельник, 31 марта 2014 г.

Типы данных float и real (Transact-SQL)

Copy from here

http://msdn.microsoft.com/ru-ru/library/ms173773.aspx

http://en.wikipedia.org/wiki/Floating_point

http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html

http://www.delphikingdom.com/asp/viewitem.asp?catalogID=374

http://www.sql.ru/forum/758492/faq-tipy-dannyh-float-i-double-neochevidnye-osobennosti-veshhestvennyh-chisel

http://dev.mysql.com/doc/refman/5.5/en/numeric-types.html

Типы данных float и real
SQL Server 2012
4 из 7 оценили этот материал как полезный Оценить эту тему
Типы приблизительных числовых данных, используемые для числовых данных с плавающей запятой. Данные с плавающей запятой являются приблизительными, поэтому не все значения из диапазона могут быть отображены точно.
Примечание Примечание
Типу real соответствует в ISO тип float(24).
Тип данных
Диапазон
Хранение
float
- 1,79E+308 — -2,23E-308, 0 и 2,23E-308 — 1,79E+308
Зависит от значения n
real
- 3,40E + 38 — -1,18E - 38, 0 и 1,18E - 38 — 3,40E + 38
4 байта
float [ (n) ]
Где n — это количество битов, используемых для хранения мантиссы числа в формате float при экспоненциальном представлении. Определяет точность данных и размер для хранения. Значение параметра n должно лежать в пределах от 1 до 53. Значением по умолчанию для параметра n является 53.
Значение n
Точность
Объем памяти
1-24
7 знаков
4 байта
25-53
15 знаков
8 байт
Примечание Примечание
В приложении SQL Server параметр n может принимать одно из двух возможных значений. Если 1<=n<=24, то параметр n принимает значение 24. Если 25<=n<=53, то параметр n принимает значение 53.
Тип данных SQL Server float[(n)] соответствует стандарту ISO для всех значений n в диапазоне от 1 до 53. Синонимом типа данныхdouble precision является тип float(53).


Значения типа float усекаются, если они преобразуются в любой целочисленный тип данных.
Если тип данных float или real нужно преобразовать в символьный тип, то, как правило, строковую функцию STR использовать удобнее, чем CAST( ). Это объясняется большими возможностями функции STR в отношении форматирования. Дополнительные сведения см. в разделах STR (Transact-SQL) и Встроенные функции (Transact-SQL).
Точность преобразования значений float, которые используют экспоненциальное представление, к decimal или numeric ограничена только 17 знаками. Любое значение с точностью, превышающей 17 знаков, округляется до нуля.

воскресенье, 30 марта 2014 г.

decimal and numeric (Transact-SQL)

Copy from Here:

http://msdn.microsoft.com/en-us/library/ms187746.aspx


decimal and numeric (Transact-SQL)

SQL Server 2012
39 out of 85 rated this helpful Rate this topic
Numeric data types that have fixed precision and scale.
decimal [ (p,s)] and numeric(p,s)]
Fixed precision and scale numbers. When maximum precision is used, valid values are from - 10^38 +1 through 10^38 - 1. The ISO synonyms for decimal are dec and dec(ps)numeric is functionally equivalent to decimal.
p (precision)
The maximum total number of decimal digits that will be stored, both to the left and to the right of the decimal point. The precision must be a value from 1 through the maximum precision of 38. The default precision is 18.
(scale)
The number of decimal digits that will be stored to the right of the decimal point. This number is substracted from p to determine the maximum number of digits to the left of the decimal point. Scale must be a value from 0 through p. Scale can be specified only if precision is specified. The default scale is 0; therefore, 0 <= s <= p. Maximum storage sizes vary, based on the precision.
Precision
Storage bytes
1 - 9
5
10-19
9
20-28
13
29-38
17


For the decimal and numeric data types, SQL Server considers each specific combination of precision and scale as a different data type. For example, decimal(5,5) and decimal(5,0) are considered different data types.
In Transact-SQL statements, a constant with a decimal point is automatically converted into a numeric data value, using the minimum precision and scale necessary. For example, the constant 12.345 is converted into a numeric value with a precision of 5 and a scale of 3.
Converting from decimal or numeric to float or real can cause some loss of precision. Converting from intsmallinttinyintfloatreal,money, or smallmoney to either decimal or numeric can cause overflow.
By default, SQL Server uses rounding when converting a number to a decimal or numeric value with a lower precision and scale. However, if the SET ARITHABORT option is ON, SQL Server raises an error when overflow occurs. Loss of only precision and scale is not sufficient to raise an error.
When converting float or real values to decimal or numeric, the decimal value will never have more than 17 decimals. Any float value < 5E-18 will always convert as 0.