对我来说,PetaPoco Database.Fetch和他Database.Query似乎在做同样的事情.
例如,
var db = new PetaPoco.Database("myDB");
ProductList products = db.Fetch<ProductList>("SELECT * FROM ProductList");
ProductList products = db.Query<ProductList>("SELECT * FROM ProductList");
Run Code Online (Sandbox Code Playgroud)
它们之间有什么显着差异吗?
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%@ page import ="java.sql.*" %>
<%@ page import = "com.mysql.jdbc.Driver" %>
<jsp:useBean id="vo" class="my.member.MemberVo"/>
<jsp:setProperty property="*" name="vo"/>
<%
Connection conn = null;
Statement stmt = null;
PreparedStatement ps = null;
String queryPerson = new String(); //Query statement
String queryUserInfo = new String();
String queryAccount = new String();
try {
Class.forName("org.gjt.mm.mysql.Driver");
} catch (ClassNotFoundException e ) {
System.out.println("JDBC error");
}
try{
conn = DriverManager.getConnection("jdbc:mysql://mysql2.cs.stonybrook.edu/jaehyeolee", "root", "");
} catch(SQLException e) {
System.out.println("Database Error");
}
System.out.println("Database connected"); …Run Code Online (Sandbox Code Playgroud) 我试图初始化一个字符串数组,如下所示,但它有一个错误.
public class Account{
private String[] account;
public Account()
{
account = {"A", "B", "C"};
}
}
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么它一直在创建错误?
我正在尝试转换Collections.Generic.List<T>为Enumerable.ToDictionary<TSource, TKey>。
我想我可以转换List到Dictionary使用ToDictionary的方法,因为ListIS IEnumerable。但是Visual Studio抱怨说这ToDictionary没有定义。
这是我的代码。
Dictionary<int, SearchResult> dic = model.ResultItems.ToDictionary(x=>index++, x=>x);
Run Code Online (Sandbox Code Playgroud)
这是对 ResultItems
public List<ResultsViewModel> ResultItems
谁能给我我如何将转换List为Dictionary?谢谢。