我有以下查询:
var MyQuery = from e in ContractContext.Equipments.Include("Manufacturers")
where e.Customers.ID == customer.ID
select e;
Run Code Online (Sandbox Code Playgroud)
一切正常,我得到我的设备,它正确加载制造商表(热切).但是,当我尝试执行以下多对多查询时:
var MyQuery = from e in ContractContext.Equipments.Include("Manufacturers")
where e.Customers.ID == customer.ID
from cce in e.ContractEquipments
where cce.Contracts.EndedOn >= DateTime.Today
select e;
Run Code Online (Sandbox Code Playgroud)
其中"ContractEquipments"是"设备"和"合同"之间的多对多查找,但是当此查询运行时,制造商表不再容易加载.知道如何在不执行以下操作的情况下解决此问题:
if (MyEntity.Manufacturers.IsLoaded == false)
MyEntity.ManufacturersReference.Load()
Run Code Online (Sandbox Code Playgroud)
这个项目需要几个小时执行,我想保持数据库调用的数量.
编辑#1:
我也尝试了这个没有成功:
var MyQuery = from e in ContractContext.Equipments.Include("Manufacturers")
where e.Customers.ID == customer.ID
join cce in ContractContext.ContractEquipments
on e.ID equals cce.Equipments.ID
where cce.Contracts.EndedOn >= DateTime.Today
select e;
Run Code Online (Sandbox Code Playgroud) 这段代码取自使用XNA框架构建的游戏.我想要解释一下它在三角形和物理学方面是如何工作的.
ball.velocity = new Vector2((float)Math.Cos(cannon.rotation),(float)Math.Sin(cannon.rotation));
ball.rotation是一个精灵的旋转,我应该想到的是弧度.
为什么他们可以使用弧度中的角度来找到x位置然后找到斜边指向的方向的y位置相同的东西.
我问这个的原因.我想了解这个框架如何计算trig.我试图让一个精灵转向鼠标所在的方向,即:x和y已知,我只需要角度.
所以这里有2个问题.解释上面的代码并将sprite指向已知点的方向.
更新:
我发现对象所在的点a不是(0,0),因为xna使用逆坐标系.所以我现在的变量是:
对象点.鼠标点.
我想知道是否有任何地图创建工具可以为2d等距游戏创建地形并将其导出为某种形式的xml或其他开放格式文档.
例如.您将创建100x100平铺地图的方式.使用画笔在图块上绘制颜色或纹理以及特定的碰撞和动画.然后导出纹理和xml,这样我就可以编写我的游戏来阅读它.
如果那里没有这样的程序.我想在开发2d地图时对这种方法提出建议.我是程序员,我的朋友是将要使用地图制作者的图形人.
如何检测滚动查看器滚动控件何时不可用并使其不可见.滚动条仅在有可能向上或向下滑动时才可见.
谢谢,肖恩麦克莱恩
<label for="AddList" class="locType">Select a location</label>
<select id="AddList">
<option value="New">New Address...</option>
</select>
Run Code Online (Sandbox Code Playgroud)
The Js.
$(document).ready(function() {
//Location Code
$("#AddList").change(function() {
var str = "";
$("#AddList option:selected").each(function() {
str += $(this).text() + " ";
});
alert(str);
})
.change();
});
Run Code Online (Sandbox Code Playgroud)
I'm trying to alert the contents whenever the user selects an option in the combobox. Also, could the code be provided to get the value of the selected option also.
Thank you
我正在使用cout将数字打印到控制台.我还将高达13亿的数值存储为数字并对其进行计算.我应该使用哪种数据类型?
当我执行以下操作时:
int a = 6800000000;
cout << a;
Run Code Online (Sandbox Code Playgroud)
它打印-1789934592.
谢谢.
我有一个服务设置如下:
public interface IMyService
{
void AddCountry(string countryName);
}
public class MyService : IMyService
{
public void AddCountry(string countryName)
{
/* Code here that access repository and checks if country exists or not.
If exist, throw error or just execute. */
}
}
Run Code Online (Sandbox Code Playgroud)
测试文件
[TestFixture]
public class MyServiceTest
{
[Test]
public void Country_Can_Be_Added()
{ }
[Test]
public void Duplicate_Country_Can_Not_Be_Added()
{ }
}
Run Code Online (Sandbox Code Playgroud)
我如何测试AddCountry和最小化存储库或服务。我真的不知道在这里做什么或嘲笑什么。有人可以帮我吗?
我正在使用的框架:
我有一个会员资格例外,如下所示:
public enum MembershipError
{
EmailNotFound,
EmailNotConfirmed,
IncorrectPassword,
EmailExists
}
public class MembershipException : ApplicationException
{
public MembershipError MembershipError { get; set; }
public MembershipException(MembershipError membershipError)
: base(Enum.GetName(typeof (MembershipError), membershipError))
{
MembershipError = membershipError;
}
}
Run Code Online (Sandbox Code Playgroud)
我应该在我的例外中使用枚举还是为每个枚举做一个例外?因为那时我会在捕获异常时使用逻辑:
try
{
}
catch (MembershipException exception)
{
switch (exception.MembershipError)
{
case MembershipError.EmailExists:
break;
//etc.
}
}
Run Code Online (Sandbox Code Playgroud)
我的服务层抛出这些异常,动作中的web层/捕获这些异常,生成正确的json并将其返回到视图.建议替代方案吗?
如果我从服务层公开IQueryable,如果我需要从多个服务中获取信息,数据库调用是否会更少?
例如,我想在页面上显示2个单独的列表,Posts和Users.我有2个单独的服务,提供这些服务的列表.如果两者都提供IQueryable,它们将在1个数据库调用中联合起来吗?每个存储库为自己创建一个上下文.
c# ×4
.net ×2
linq ×2
c++ ×1
exception ×1
javascript ×1
jquery ×1
moq ×1
nunit ×1
physics ×1
silverlight ×1
trigonometry ×1
xna ×1