假设我的一个控制器中有这样的方法:
[Route("api/Products")]
public IQueryable<Product> GetProducts() {
return db.Products
.Include(p => p.Category);
}
Run Code Online (Sandbox Code Playgroud)
使用这个我可以从数据库中获取产品并包含其Category属性.
在我的CategoryControllerI中有这个方法:
[Route("api/Categories")]
public IQueryable<Category> GetCategories() {
return db.Categories
.Include(c => c.Parent)
.Include(c => c.Products)
.Include(c => c.SubCategories);
}
Run Code Online (Sandbox Code Playgroud)
当我向CategoryController发送GET请求时,它按预期工作,我得到类别,其父级,产品和子类别.但是,当我向ProductController发送GET请求时,我不想将所有产品都包含在所请求产品的类别中,我只需要有关该类别的基本信息.
那么,我如何让GetProducts()返回数据库中的产品,包括每个产品的Category属性,但不包括该类别的Products列表属性,仍然保留其他属性,如id,title等?
谢谢.
我目前正在成功使用下面的代码来使用Selenium webdriver的代理.不幸的是,我似乎无法在不重新启动整个浏览器的情况下更改代理设置.我曾希望简单地更新代理设置,就像我设置代理开始一样,会改变代理,但它似乎不起作用.对此主题的任何帮助将不胜感激.
profile = webdriver.FirefoxProfile()
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http", proxyAddress)
profile.set_preference("network.proxy.http_port", proxyPort)
profile.update_preferences()
driver = webdriver.Firefox(firefox_profile=profile)
Run Code Online (Sandbox Code Playgroud) 我在LibGDX中使用Shape Renderer绘制一条线,我在我的代码中使用正交相机,所以增加我使用的宽度
camera = new OrthographicCamera();
int lineWidth = 8; // pixels
Gdx.gl10.glLineWidth(lineWidth / camera.zoom);
Run Code Online (Sandbox Code Playgroud)
现在,我得到更广泛的界限.但是当屏幕电源关闭然后再打开时,问题就出现了,线路再次成为正常线路.如何保持宽度不变?
我做了一个小小的"游戏"来测试我在实际游戏中注意到的一些口吃,我不能为我的生活弄清楚为什么会这样.我做了一个最简单的项目,我可以测试一下,但我仍然得到相当沉重的口吃.FPS仍然是60,但每隔几秒,有时甚至更多,游戏将会口吃.
我已经在移动和高端电脑上尝试过它,奇怪的是,它在PC上更加引人注目,尽管它仍然出现在手机上.
我无法上传它的视频,因为它已经在录制中消失了,所以如果你想测试它,可以自己编译项目.这是代码:
public class LagTest extends ApplicationAdapter {
SpriteBatch batch;
Texture dot;
float x;
float y;
float speed;
float dotWidth;
int screenWidth;
@Override
public void create () {
batch = new SpriteBatch();
dot = new Texture("dot.png");
x = 100;
y = Gdx.graphics.getHeight()/2 - dot.getHeight()/2;
speed = 500;
dotWidth = dot.getWidth();
screenWidth = Gdx.graphics.getWidth();
}
@Override
public void render () {
Gdx.gl.glClearColor(0.2f, 0.4f, 0.8f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(dot, x, y);
batch.end();
if (x < 0) {
speed = 500;
} …Run Code Online (Sandbox Code Playgroud) 我有以下文字:
2 HCl + 12 Na + 3 (Na?Cl?)?? ? 2 NaCl + H?
我想匹配每个分子,包括它的系数.下面的正则表达式几乎正常工作,但是在最后一场比赛之前的空格字符正在匹配,它不应该匹配.这是我正在使用的正则表达式:
(([0-9]* ??\(*([a-z]+[?-?]*)+\)*[?-?]*))
如果您查看此regex101链接,可能更容易看到我的问题:https://regex101.com/r/hK7jY6/1
我已经阅读了有关scene2d的UI功能的一些教程和文档,但我无法弄清楚外观是如何工作的.我只想要一个TextButton,在按下时会改变颜色.我设法让TextButton的背景改变,但那不是我想要的.它应该没有背景.
如果有人能提供一个如何做到这一点的例子,我将非常感激.这看起来很简单,所以我觉得我在这里遗漏了一些明显的东西.如果涉及皮肤,请以编程方式编写.
谢谢.
我想知道如何在libgdx中为我的事件添加时间.我有一个按钮,按下它时会出现一个精灵.我希望精灵只出现一小段时间.我怎样才能做到这一点?我使用Scene2D将sprite作为演员.
我将在伪代码中向您展示一个示例.
wait time = 5 second;
current time = get time;
if (current time > wait time) {
// do the following
}
Run Code Online (Sandbox Code Playgroud)