我的代码应该检查两个条件并返回值,但是当我尝试返回q时时,会出现此错误
无法将类型“System.Collections.Generic.List<<匿名类型:字符串名称,字符串文件>>”隐式转换为“System.Collections.Generic.List<字符串>”
我尝试了一切,但没有任何效果,也不知道如何设置List<string>其设置为List<EF_Model.PDF>,PDF 是我模型中的 DTO
这是我的代码
internal List<string> Customers_File(int _id)
{
using (var Context = new EF_Model.CoolerEntities())
{
var q = from c in Context.Customers
where c.Id == _id &&
c.Ref_PDF != null
select new { c.PDF.Name, c.PDF.File };
return q.ToList();
}
}
Run Code Online (Sandbox Code Playgroud) 这是我的代码(这是简单的电话簿,这是删除其中的一部分)
private void btnDeleteFromGV_Click(object sender, EventArgs e)
{
try
{
dataGridView1.Rows.RemoveAt(dataGridView1.SelectedRows[0].Index);
}
catch (Exception)
{
MessageBox.Show("PLS Enter a Row");
}
}
Run Code Online (Sandbox Code Playgroud)
我想在数据网格视图中同时选择两行或更多行并能够删除它们
我应该怎么办!?
我需要获取一些数据并在其他级别使用它.我不能回来(c),我正在寻找一种模式.我怎样才能正确归还?
public string AutoUpdate(string _search)
{
using (var context = new Phone_BookEntities1())
{
var c = from d in context.Cantacts
where d.Cantact1 == _search
select d.Cantact1.ToString();
return c;
}
}
Run Code Online (Sandbox Code Playgroud) 我首先得到两个运行时错误({"序列包含多个元素"} ==> System.InvalidOperationException)当它出现不止一次时以及当我想删除我在文本框中写的内容时该怎么办? ?
这是我的代码
private AutoCompleteStringCollection GetLinqDataSourceForString(string p)
{
var c = new AutoCompleteStringCollection();
c.Add( Getauto(p));
return c;
}
private void txtSearch_TextChanged(object sender, EventArgs e)
{
txtSearch.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtSearch.AutoCompleteMode = AutoCompleteMode.Suggest;
txtSearch.AutoCompleteCustomSource = GetLinqDataSourceForString(txtSearch.Text);
}
Run Code Online (Sandbox Code Playgroud)
而这一个是在另一层从数据库获取信息
public string AutoUpdate(string _search)
{
using (var context = new Phone_BookEntities1())
{
var c = (from d in context.Cantacts
where d.Cantact1.StartsWith(_search)
select d.Cantact1).SingleOrDefault();
return c;
}
}
Run Code Online (Sandbox Code Playgroud)