Linq包含从vs2010迁移到vs2012后无法正常工作

时间:2016-05-12 20:42:28

标签: c# linq visual-studio-2010 visual-studio-2012

我只是将我的项目从vs2010迁移到vs2012,当我尝试执行此方法时,该语句似乎没有数据。相同的代码在vs2010上运行良好。

public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { 

NavigationView navigationView = null;
Toolbar toolbar = null;
FragmentManager fragmentManager = getSupportFragmentManager();

@Override protected void onCreate(Bundle savedInstanceState) {

 super.onCreate(savedInstanceState); 
 setContentView(R.layout.activity_main);

 //set initial fragment to 'new' instead 
 addFragment(new NewFragment(), true); 

 //Set the toolbar
 toolbar = (Toolbar) findViewById(R.id.toolbar);
 setSupportActionBar(toolbar); 

 //Set navigation drawer
 DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
 ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
 drawer.setDrawerListener(toggle);
 toggle.syncState();
 navigationView = (NavigationView) findViewById(R.id.nav_view);
 navigationView.setNavigationItemSelectedListener(this); 
}

@Override public void onBackPressed() {
  DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);

  if (drawer.isDrawerOpen(GravityCompat.START)) {
    drawer.closeDrawer(GravityCompat.START); } 
  else { 
  //put your alert dialog code here //
   if (getFragmentManager().getBackStackEntryCount() == 0) ...
  }
} 

@SuppressWarnings("StatementWithEmptyBody") 
@Override 
public boolean onNavigationItemSelected(MenuItem item) {

// Handle navigation view item clicks here. 
int id = item.getItemId(); 
// Replace these with your own menu items 
 switch (id) { 
    case R.id.nav_start: 
      addFragment(new StartFragment(), true);
      break;
    case R.id.nav_save: 
      addFragment(new SaveFragment(), true);
      break; 
    case R.id.nav_raw: 
      addFragment(new RawFragment(), true);
      break; 
    case R.id.nav_gyroscope: 
      addFragment(new GyroscopeFragment(), true); 
      break; 
 } 

 DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
 drawer.closeDrawer(GravityCompat.START);
 return true; 
 } 

public void addFragment(Fragment fragment, Boolean addToBackStack) {
  if (fragment != null) {
   FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
   fragmentTransaction.replace(R.id.fragment_container, fragment, fragment.getClass().getSimpleName()) .addToBackStack(null) .commit();

  } 
 } 
}

欢迎任何解决此问题的建议。

2 个答案:

答案 0 :(得分:0)

我通过升级到EntityFramework6来解决它,似乎EntityFramework5仍然有一些错误。我使用相同的方法和数据,但现在我得到了预期的数据。

答案 1 :(得分:0)

我认为在升级EntityFramework时遇到了类似的问题,因此我转而使用.Any()方法。