C# 重熔,例如长度、质量、次数等。这样你就可以避免试图用板条箱装一件6个谷仓、1个星期、9块石头的物品。 public class ItemDimensions{ public int width {get;set;} public int height

C# 重熔,例如长度、质量、次数等。这样你就可以避免试图用板条箱装一件6个谷仓、1个星期、9块石头的物品。 public class ItemDimensions{ public int width {get;set;} public int height,c#,sql-server,asp.net-mvc,C#,Sql Server,Asp.net Mvc,重熔,例如长度、质量、次数等。这样你就可以避免试图用板条箱装一件6个谷仓、1个星期、9块石头的物品。 public class ItemDimensions{ public int width {get;set;} public int height {get;set;} public int depth {get;set;} public int weight {get;set;} } Item table -- ... -- other fields Width decimal

重熔,例如长度、质量、次数等。这样你就可以避免试图用板条箱装一件6个谷仓、1个星期、9块石头的物品。
public class ItemDimensions{

 public int width {get;set;}
 public int height {get;set;}
 public int depth {get;set;}
 public int weight {get;set;}

}
Item table
--
... -- other fields
Width decimal(38,6) -- you can decide on precision
Height decimal(38,6) -- you can decide on precision
Depth decimal(38,6) -- you can decide on precision
DimentionTypeId int FK -- the 3 above would use the same dimention type?
Weight


DimentionType table
--
DimentionTypeID int PK
Description
... -- other fields
SELECT COUNT(*)
FROM Items
WHERE Length BETWEEN 0.150 AND 0.300
SELECT AVG(Weight)
FROM Items
WHERE (Length * Width * Height) < 1
SELECT COUNT(*)
FROM
(
    SELECT i.LengthValue * c.Factor AS Length
    FROM Items i
    JOIN Conversion c ON c.FromUnit = i.LengthUnit
    WHERE i.ToUnit = 'm'
) l
WHERE Length BETWEEN 0.150 AND 0.300
SELECT AVG(WeightKg)
FROM
(
    SELECT i.LengthValue * lc.Factor AS LengthM,
        i.WidthValue * wc.Factor AS WidthM,
        i.HeightValue * hc.Factor AS HeightM,
        i.WeightValue * mc.Factor AS WeightKg
    FROM Items i
    JOIN Conversion lc ON lc.FromUnit = i.LengthUnit
    JOIN Conversion wc ON wc.FromUnit = i.WidthUnit
    JOIN Conversion hc ON hc.FromUnit = i.HeightUnit
    JOIN Conversion mc ON mc.FromUnit = i.WeightUnit -- 'm' for 'mass'
    WHERE lc.ToUnit = 'm' AND wc.ToUnit = 'm' AND hc.ToUnit = 'm' 
        AND mc.ToUnit = 'Kg'
) d
WHERE (LengthM * WidthM * HeightM) < 1