在PostgreSQL中,我有一个带varchar列的表.数据应该是整数,我在查询中需要整数类型.有些值是空字符串.下列:
SELECT myfield::integer FROM mytable
Run Code Online (Sandbox Code Playgroud)
产量 ERROR: invalid input syntax for integer: ""
如何在postgres中投射期间查询演员并且在出现错误时为0?
如何设置我的Moq以返回一些值并让测试的服务选择正确的?
IRepository:
public interface IGeographicRepository
{
IQueryable<Country> GetCountries();
}
Run Code Online (Sandbox Code Playgroud)
服务:
public Country GetCountry(int countryId)
{
return geographicsRepository.GetCountries()
.Where(c => c.CountryId == countryId).SingleOrDefault();
}
Run Code Online (Sandbox Code Playgroud)
测试:
[Test]
public void Can_Get_Correct_Country()
{
//Setup
geographicsRepository.Setup(x => x.GetCountries()).Returns()
//No idea what to do here.
//Call
var country = geoService.GetCountry(1);
//Should return object Country with property CountryName="Jamaica"
//Assert
Assert.IsInstanceOf<Country>(country);
Assert.AreEqual("Jamaica", country.CountryName);
Assert.AreEqual(1, country.CountryId);
geographicsRepository.VerifyAll();
}
Run Code Online (Sandbox Code Playgroud)
我基本上坚持设置.
activity_main.xml中:
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:elevation="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"
/>
Run Code Online (Sandbox Code Playgroud)
bottom_bar.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/tab_addcard"
android:enabled="true"
android:title="@string/addcard"
android:icon="@drawable/ic_tabicon_addcard"
app:showAsAction="ifRoom|withText"/>
<item
android:id="@+id/tab_approvals"
android:enabled="true"
android:title="@string/approvals"
android:icon="@drawable/ic_tabicon_approvals"
app:showAsAction="always|withText"/>
<item
android:id="@+id/tab_mycard"
android:enabled="true"
android:title="@string/mycard"
android:icon="@drawable/ic_tabicon_mycard"
app:showAsAction="always|withText"/>
Run Code Online (Sandbox Code Playgroud)
MainActivity.java:
BottomNavigationView bottombar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bottombar= (BottomNavigationView) findViewById(R.id.bottom_navigation);
bottombar.inflateMenu(R.menu.bottom_bar);
}
Run Code Online (Sandbox Code Playgroud)
我的问题是:在完成从底栏的初始化到添加项目的所有内容之后.一旦我运行它并快速(非常快)地尝试BottomNavigationView
突然间中间项目标题文本的项目选项卡之间的切换消失.任何人都可以建议我解决方案吗?
我有一些看起来像这样的短代码:
public static IQueryable<User> SelectFromEmployee(int employee)
{
using (var ctx = Database.AccountingContext())
{
return ctx.Users.Where(c => c.Employee_FK == employee);
}
}
Run Code Online (Sandbox Code Playgroud)
如果我只是保持这个代码,并使用结果我得到异常告诉我数据被处置.但如果我喜欢这样:
public static IEnumerable<User> SelectFromEmployee(int employee)
{
using (var ctx = Database.AccountingContext())
{
return ctx.Users.Where(c => c.Employee_FK == employee).ToList();
}
}
Run Code Online (Sandbox Code Playgroud)
一切正常.但我的问题是我想使用需要IQueryable的Linq Dynamic.有没有办法返回本地IQueryable所以我可以继续使用它?
我正在尝试填写Dictionary<long, Data>
。返回数据的方法GetData
是异步的,所以我使用以下代码来获取字典:
var myDictionary = entities
.GroupBy(e => e.EntityId)
.Select(e => e.First())
.ToDictionary(e => e.EntityId, async entity => await GetData(entity));
Run Code Online (Sandbox Code Playgroud)
不幸的是 myDictionary 是类型Dictionary<long, Task<Data>>
如何在ToDictionary中填写using async lambda?
在 VS Code 中搜索时,我使用“在编辑器中打开”选项,该选项在编辑选项卡中打开搜索结果。我唯一怀念的是直接在此选项卡中进行编辑。双击会将您带到特定文件,您可以在那里进行编辑,但内联编辑会让事情变得更轻松。
是否有任何选项如何在搜索结果编辑器选项卡中进行内联编辑?
是否有可能将IQueryable对象转换为IQueryable,其中T是映射实体?(T将是POCO类).
提前致谢.
在尝试基于NHibernate测试以下IRepository时遇到了问题:
public class NHibernateRepository<T>: Disposable, IRepository<T>
where T : IdentifiableObject
{
...
public IQueryable<T> Query()
{
return NHibernateSession.Linq<T>();
}
}
Run Code Online (Sandbox Code Playgroud)
如何在地狱中模拟IQueryable<T>
以返回给出集合的方式返回某些表达式.我觉得我有一些误解IQueryable<T>
......
我正在尝试根据从 Component.ts 获取的值来禁用输入
在我的component.ts
文件中我有这个值
disName = false;
Run Code Online (Sandbox Code Playgroud)
在我的 HTML 中我有这些元素
Name: <input type="text"
value="name"
size="15"
id="name"
name="firstName"
[(ngModel)]="aproverFirstName"
[attr.disable]="disName=='true' ? true : null">
Run Code Online (Sandbox Code Playgroud)
寻找的是,如果我的值是component.ts
false,那么在 html 文件中,输入元素应该根据该值更改为禁用。
我也尝试过这个[disable]="disName"
我正在使用 Angular 7,非常感谢!
linq ×3
c# ×2
android ×1
angular ×1
angular7 ×1
angularjs ×1
async-await ×1
casting ×1
dictionary ×1
html ×1
input ×1
java ×1
linq-to-sql ×1
moq ×1
nunit ×1
postgresql ×1
sql ×1
ui-grid ×1
unit-testing ×1
xml ×1