小编Ela*_*nda的帖子

db如何自动生成uniqueindentifier?

我有一个带id(guid)列的sql表.如何强制数据库为每个新记录自动生成一个新的guid?

sql t-sql sql-server

10
推荐指数
1
解决办法
1万
查看次数

LINQ中Sum和Aggregate的区别

两个函数之间的差异是什么:Sum/Aggregate?

c# linq

10
推荐指数
2
解决办法
3020
查看次数

找到一个名为".git/.MERGE_MSG.swp"的交换文件

我试过了 pull origin branschName

并得到这个奇怪的错误:

error: There was a problem with the editor 'vi'.
Not committing merge; use 'git commit' to complete the merge.


E325: ATTENTION
Found a swap file by the name ".git/.MERGE_MSG.swp"
          owned by: eladb   dated: Tue Aug 20 10:52:03 2013
         file name: ~eladb/MyWorkspace/Client/.git/MERGE_MSG
          modified: no
         user name: eladb   host name: Elads-MacBook-Pro-2.local
        process ID: 29959 (still running)
While opening file ".git/MERGE_MSG"
             dated: Tue Aug 20 10:53:11 2013
      NEWER than swap file!

(1) Another program may be editing the …
Run Code Online (Sandbox Code Playgroud)

java svn git version-control github

10
推荐指数
1
解决办法
1万
查看次数

将datareader值转换为a到Nullable变量

我正在尝试运行以下代码,但得到一个转换错误.如何重写我的代码以实现相同的目标?

boolResult= (bool?)dataReader["BOOL_FLAG"] ?? true;
intResult= (int?)dataReader["INT_VALUE"] ?? 0;
Run Code Online (Sandbox Code Playgroud)

谢谢

c# sql

9
推荐指数
3
解决办法
1万
查看次数

LINQ to Entities无法识别方法'System.String Format

我怎样才能重构这个LINQ以使其工作?

var a =  (from app in mamDB.Apps where app.IsDeleted == false 
                select string.Format("{0}{1}",app.AppName, 
                app.AppsData.IsExperimental? " (exp)": string.Empty))
               .ToArray();}
Run Code Online (Sandbox Code Playgroud)

我现在得到错误:

LINQ to Entities无法识别方法'System.String Format(System.String,System.Object,System.Object)'方法,并且此方法无法转换为商店表达式.

我无用地尝试过:

return (from app in mamDB.Apps where app.IsDeleted == false 
        select new string(app.AppName + (app.AppsData != null && 
        app.AppsData.IsExperimental)? " (exp)": string.Empty)).ToArray();
Run Code Online (Sandbox Code Playgroud)

.net c# linq asp.net

9
推荐指数
1
解决办法
9516
查看次数

如何解决EF:表的潜在运行时违规

我在我的网络应用程序中使用EF 4.

这是我的相关表格:

**AppToDomains_V1 **
GroupId   uniqueidentifier
AppGuid   uniqueidentifier

**Apps table**
AppName   nvarchar(50)  
AppGuid   uniqueidentifier  
ClientAppID   nvarchar(50)  
IsDeleted     bit   
CreatedDate   datetime  
UpdatedDate   datetime  
Run Code Online (Sandbox Code Playgroud)

和我的edmx:

http://ge.tt/17n6R2e/v/0?c

我收到以下错误:

错误2错误3002:问题在映射片段起始于线1565:潜在的运行时违反表AppToDomains_V1的键(AppToDomains_V1.AppId,AppToDomains_V1.Domain)的:列(AppToDomains_V1.AppId,AppToDomains_V1.Domain)被映射到的EntitySet AppToDomains_V1的属性(AppToDomains_V1.的AppId,AppToDomains_V1.Domain)的概念的一面,但他们并不构成的EntitySet的键属性(AppToDomains_V1.AppId,AppToDomains_V1.Domain,AppToDomains_V1.IsWhiteListed).d:\ MAM \服务器\ MamAdmin \开发\管理1.7\MaMDBEntityFramework\MaMModel.edmx 1566 15 MaMDBEntityFramework

我该如何解决这个问题?

d:\ MAM \服务器\ MamAdmin \开发\管理员

1.7\MaMDBEntityFramework\MaMModel.edmx 1566 15是:

      <EntitySetMapping Name="AppToDomains_V1">
        <EntityTypeMapping TypeName="MaMDBModel.AppToDomains_V1">
          <MappingFragment StoreEntitySet="AppToDomains_V1">
            <ScalarProperty Name="IsWhiteListed" ColumnName="IsWhiteListed" />
            <ScalarProperty Name="Domain" ColumnName="Domain" />
            <ScalarProperty Name="AppId" ColumnName="AppId" />
          </MappingFragment>
        </EntityTypeMapping>
      </EntitySetMapping>
Run Code Online (Sandbox Code Playgroud)

c# sql asp.net-mvc entity-framework

9
推荐指数
1
解决办法
4258
查看次数

如何在android线性布局中对齐父底部?

我有一个线性布局

我想在它的底部创建一个切片.

我知道有一些选择,但我有点困惑

1)android:layout_gravity:"bottom"- >由于某些原因,这对我不起作用.

2)android:gravity_weight="0"并给它前面的兄弟姐妹android:gravity_weight:"1"

3)android:height="wrap_content"并给它之前的兄弟姐妹android:height:"match_parent"

我知道如何使用relativeLayout执行此操作,但我想练习linearLayout

你会建议什么?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/blue_bg"
    android:orientation="vertical" >

   <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginTop="5dp"
        android:src="@drawable/signup_illu_why" />
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight=""
        android:orientation="horizontal" />

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/signup_skip_icon" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

java layout android android-layout

9
推荐指数
4
解决办法
5万
查看次数

IntelliJ中的刷新gradle导致源文件夹结构发生变化

当我gradle在IntelliJ IDEA中运行刷新时,我的主文件夹被设置为源根,但是"java",这是我的实际源根,没有标记.

我每次都要手动更改gradle refresh.

你知道相关的gradle设置是什么吗?

它可以在一个通用gradle文件中吗?

我应该将main文件夹更改为源根吗?

在此输入图像描述

在此输入图像描述

我怎么知道我可以继承的常用gradle在哪里?我如何在当地覆盖这个build.gradle

我的build.gradle:

apply plugin: 'java'
apply plugin: 'application'

sourceCompatibility = 1.8
version = '1.0'

repositories {
    mavenCentral()
}

dependencies {
//
//    configurations.all*.exclude(group: 'com.sun.jersey', module: 'jersey-bundle')
//    configurations.all*.exclude(group: 'com.fasterxml.jackson.core', module:'jackson-databind')


    compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'

    compile 'com.google.inject:guice:4.0-beta5'
    compile 'com.sun.jersey:jersey-core:1.18.3'
    compile 'com.sun.jersey:jersey-client:1.18.3'
    compile 'com.sun.jersey:jersey-json:1.18.3'
    compile 'com.sun.jersey.contribs:jersey-apache-client:1.18.3'
    compile group: 'junit', name: 'junit', version: '4.11'
    compile 'com.vividsolutions:jts:1.13'
    compile 'net.sf.opencsv:opencsv:2.3'
    compile 'com.googlecode.json-simple:json-simple:1.1'
    compile 'com.google.guava:guava:18.0'

    //testCompile group: 'junit', name: 'junit', version: …
Run Code Online (Sandbox Code Playgroud)

java intellij-idea gradle

9
推荐指数
1
解决办法
5649
查看次数

android.support.v4.util.Pair vs android.util.Pair

我读到了关于support.v4允许android向后兼容的lib.

因此,当存在歧义时,IIUC始终是从列表中导入lib的最佳实践 android.support.v4 ...

对?

在此输入图像描述

java android android-support-library

9
推荐指数
1
解决办法
1839
查看次数

Robolectric对于包含包装内容高度的视图返回0高度

我有一个要测试的android customView。

当N为subView高度时,很少有测试能够模拟N dps的滚动。

我使用robolectric运行测试,但是我总是在运行时获得 subView.getHeight() == 0

这是因为subView的高度定义为wrap_content,我想robolectric不会使所有视图膨胀以获取此准确信息。

例如,subView.getWidth > 0按定义为match parent

这是我的测试@before方法:

@Before
  public void setUp() {

    myView.getHeaderView().getViewTreeObserver().addOnGlobalLayoutListener(
        new OnGlobalLayoutListener() {
          @Override
          public void onGlobalLayout() {
            myHeight =
                myView.getHeaderView().getHeight();
          }
        });

    activityScenarioRule
        .getScenario()
        .onActivity(activity -> activity.setContentView(myView));
    activityScenarioRule.getScenario().moveToState(State.RESUMED);
  }
Run Code Online (Sandbox Code Playgroud)

在测试运行时如何仍然获得包装内容的高度?

该代码确实调用onGlobalLayout但返回height==0

layout android view robolectric layout-inflater

9
推荐指数
1
解决办法
136
查看次数