我如何实现以下四舍五入?
0.012608376> 0.015
2.1> 2.5
2.4> 2.5
2.5> 2.5
2.6> 3
.01> .05
我有以下方法:
public IEnumerable<MyRosterDTO> MyRosterGetCustomers(
IEnumerable<Guid> SalesRepIds,
IEnumerable<Guid> escrowOfficerIds,
IEnumerable<int> targetTypes,
IEnumerable<int> tagIds,
IEnumerable<Guid> custTypes,
IEnumerable<int> distListIds,
bool myExceptions)
{
customerStatusLog cslAlias = null;
customer custAlias = null;
customerOptions coAlias = null;
employee salesRepAlias = null;
Office officeAlias = null;
ListTags tagsAlias = null;
MyRosterDTO dto = null;
contactInformation contactInfo = null;
var myRosterQuery = _sms.CurrentSession.QueryOver<customer>(() => custAlias)
.JoinAlias(c => c.CustomerOptions, () => coAlias)
.Left.JoinAlias(c => c.SalesRep, () => salesRepAlias)
.JoinAlias(c => coAlias.Company, () => officeAlias)
.Left.JoinAlias(c => c.ContactInfo, () => …Run Code Online (Sandbox Code Playgroud) 我正在使用Java Optionals.
String in = "sam";
String ret = Optional.ofNullable (in).orElse ("NULL"); // "sam"
in = null;
ret = Optional.ofNullable (in).orElse ("NULL"); // "NULL"
Run Code Online (Sandbox Code Playgroud)
如果它不为null,是否可以扩展我的可选项以返回更改的值?
让我们说"#sam#"而不是"sam"和"NULL"在情况下null.
如果我已经改变了
in = "#" + in + "#"
Run Code Online (Sandbox Code Playgroud)
它永远不会null,如果in == null它会返回"#null#"而不是"NULL".
我希望加入两个专栏......这是一个想法......
=======================================================
id | firstname | lastname
=======================================================
1 | Peter | Das
-------------------------------------------------------
2 | Das | James
-------------------------------------------------------
3 | vector | Call
______________________________________________________________
4 | cans | Das
Run Code Online (Sandbox Code Playgroud)
sql查询应该看起来像这样(伪代码)
SELECT (lastname WHERE firstname='Das' AND firstname WHERE lastname='Das'
ORDER BY ID DESC) AS name
Run Code Online (Sandbox Code Playgroud)
结果集看起来应该是这样的
======================
name
======================
cans
---------------------------------------
James
---------------------------------------
Peter
Run Code Online (Sandbox Code Playgroud)
现在任何人都可以告诉我什么是确切的查询
每个想法提示建议都是受欢迎的
我正在使用Nhibernate 3.0并需要在网站上实现分页.基本上我们有一个ProductCategory,它有一个与之关联的产品集合.到目前为止,我有这个确实有效
var result = Session.QueryOver<TEntity>().TransformUsing(Transformers.DistinctRootEntity)
.Where(category => category.CategoryId == criteria.CategoryId)
.Fetch(category => category.Products).Eager
.Take(pageSize)
.Skip((pageIndex - 1)*pageSize)
.Future<TEntity>();
Run Code Online (Sandbox Code Playgroud)
这将返回我正在请求的类别,并根据传入的页面大小和页面索引正确分页子产品.
我现在想要做的实际上是获得产品的总行数,例如,即使我只返回5个产品,我需要知道总共有100个.
非常感谢
class Program
{
static void Main(string[] args)
{
Int64 a = Int64.MaxValue;
Int64 b= Int64.MinValue;
try
{
checked
{
Int64 m = a * b;
}
}
catch (OverflowException ex)
{
Console.WriteLine("over flow exception");
Console.Read();
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果变量声明为int,我得到编译错误,转换是从int到long的requreid.
Int32和Int64Int32和Int64,它依赖于操作系统?我使用此函数来计算哈希值:
public string GetSHA512(string input)
{
byte[] data, result;
StringBuilder hash = new StringBuilder();
data = Encoding.UTF8.GetBytes(input);
using (SHA512 shaM = new SHA512Managed())
{
result = shaM.ComputeHash(data);
}
for (int i = 0; i < result.Length; i++)
{
hash.Append(result[i].ToString());
}
return hash.ToString();
}
public string GetSHA256(string input)
{
byte[] data, result;
StringBuilder hash = new StringBuilder();
data = Encoding.UTF8.GetBytes(input);
using (SHA256 shaM = new SHA256Managed())
{
result = shaM.ComputeHash(data);
}
for (int i = 0; i < result.Length; i++)
{ …Run Code Online (Sandbox Code Playgroud)