我需要检查List是否包含指定的3以外的任何值.
示例:我有这个 var sourceList = new List<string>("A", "B", "C", "D", "E");,我想检查该列表是否包含任何值BESIDES"E","F","G".只是一个Bool很好,并且sourceList是用户可能选择的预定义列表的动态子集.我的BESIDES列表将是静态的.
谢谢,
我的控制器中有以下代码:
public List<DockDoorViewModel> GetDoorViewModel()
{
List<DockDoorViewModel> doors = new List<DockDoorViewModel>();
for (int i = 1; i < 11; i++)
{
// This is where the Stack Trace is pointing to.
DockDoorViewModel door = db.vwDockDoorDatas
.Where(x => x.DockNo == i)
.Select(x => x.ToDockDoorViewModel())
.FirstOrDefault();
if (door == null)
{
door = new DockDoorViewModel(i);
}
else
{
door.Items = db.vwDockDoorDatas
.Where(x => x.DockNo == i)
.Select(x => x.ToDockDoorItem())
.ToList();
}
doors.Add(door);
}
return doors;
}
Run Code Online (Sandbox Code Playgroud)
当我尝试运行Web应用程序时,我收到此异常:
异常详细信息:System.NotSupportedException:LINQ to Entities无法识别方法'DockDoorMonitor.Models.DockDoorViewModel ToDockDoorViewModel(DockDoorMonitor.Models.vwDockDoorData)'方法,并且此方法无法转换为商店表达式.
这是扩展方法:
public …Run Code Online (Sandbox Code Playgroud) 我试图将一个值数组传递给一个表对象的数组,以便我可以将它们写入数据库.
我的数据库看起来像这样 - >
tblCaseNotes
CaseNoteID | PersonId | 等等
tblCaseNotesContactType
rowguid | CaseNoteID | ContactTypeID
tblMaintItems
itemID | 类别ID
Maint表中的itemID是与当前CaseNoteID一起写入tblCaseNotesContactType的内容.每个CaseNote可以有多个ContactType.
到目前为止,我在btnNew_Click事件中创建的CheckListBox ContactType的值数组:
// Contact Type check list box
int cTypeCount = chkContactType.CheckedItems.Count;
int [] contactTypes = new int[cTypeCount];
// reusable generic counter for looping thru the check lists
int cMaintCounter = 0;
foreach (int checkedItem in chkContactType.CheckedIndices)
{
contactTypes[cMaintCounter] = (int)chkContactType.GetItemValue(checkedItem);
cMaintCounter++;
}
CurrentCaseNote.AddCNote(Program._CurrentPerson.PersonID, Convert.ToDecimal(tbxTimeSpentUnits.Text), chkIsCaseLog.Checked, Convert.ToDateTime(datContactDate.Text), memContactDetails.Text, contactTypes);
Run Code Online (Sandbox Code Playgroud)
然后我将其传递给我的CurrentCaseNote对象AddCNote方法.
public static void AddCNote(int personID, decimal tsUnits, bool isCaseLog, …Run Code Online (Sandbox Code Playgroud) 是否可以通过get/set执行此操作?像下面这样的东西?这对我有用,但我担心我遗失了一些东西,更不用说所有的静态了.
///<summary>
/// Class to track and maintain Heads Up Display information
///</summary>
public static class HUD
{
///<summary>
///Declare variables to store HUD values
///</summary>
private static string _lastName;
private static string _firstName;
private static string _middleName;
private static string _suffix;
private static string _sSN;
private static string _personID;
private static string _masterID;
private static string _enrollmentID;
private static string _planID;
// Store a reference to THE form that holds the HUD and is …Run Code Online (Sandbox Code Playgroud) 我已经通过WinWord设置了拼写检查,但我需要找到一种方法来确保在系统上安装Word 2007.
我已经看过这个注册表版本,但我也读到它可以提供误报.所以我在"市场"中就像弄清楚如何实现这一目标一样.它可以像File.Exists()在2007文件路径中使用WinWord.exe 一样简单吗?
还有其他想法吗?
我需要一个SQL查询,按PlanDate每个ClientID 返回前两个计划.这是一个表,其中PlanID是PrimaryID,ClientID是一个foreignID.
这是我到目前为止 - >
SELECT *
FROM [dbo].[tblPlan]
WHERE [PlanID] IN (SELECT TOP (2) PlanID FROM [dbo].[tblPlan] ORDER BY [PlanDate] DESC)
Run Code Online (Sandbox Code Playgroud)
显然,这只返回2条记录,其中我实际上需要最多2条记录ClientID.
我将数据从一个页面的一部分拉到另一个页面以构建菜单.我需要将数据拉入隐藏的元素或变量,因为我现在最终得到了一个重复的菜单.我的动态飞出了静电<ul><li>.菜单由这些菜单构成.
这是我到目前为止:
<script type="text/javascript">
$(document).ready(function(){
$('div.ms-quickLaunch').replaceWith('<div id="hierarchy" style="border:solid 1px white; width:0px; visibility:hidden"></div>');
});
$(function(){
$('#hierarchy').load('http://wwcshare/icenter/Pages/wwcMenuContent.aspx #menuContent',
function(){
$(this).menu({
autoShow: true,
content: $(this).html(),
backLink: false,
crumbDefaultText: ' '
});
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
除了我的菜单不再被放置在它所属的位置之外,这是有效的.它位于页面顶部而不是侧面#hierarchy div.
这是我基于其中一个答案的替代尝试:
$(function(){
$.get('http://wwcshare/icenter/Pages/wwcMenuContent.aspx', function(data){ // grab content from another page
contentIwant = data.find("#menuContent");
$('#hierarchy').menu({
autoShow: true,
content: contentIwant,
backLink: false,
crumbDefaultText: ' '
});
});
});
Run Code Online (Sandbox Code Playgroud) 我有下面的Linq To SQL方法.当我单步执行代码spcCodeIDs包含我期待的七个条目时.但是我得到了一个运行时例外
Method 'Boolean Contains(System.String)' has no supported translation to SQL.
我错过了什么?
public static DataTable GetSPCCodeList()
{
using (var context = ProviderDataContext.Create())
{
IQueryable<tblProviderAdminSPCCode> tSPCCode = context.GetTable<tblProviderAdminSPCCode>();
IList<string> spcCodeIDs = BLLCmo.FCApprovedSPCsForGreenSheet();
return (tSPCCode
.Where(spcCode => spcCode.Inactive == null && spcCodeIDs.Contains(spcCode.SPCCodeID))
.OrderBy(spcCode => spcCode.SPCCodeID)
.Select(spcCode => new { spcCode.SPCCodeID, spcCode.SPCDescription, spcCode.SPCCategoryID }))
.CopyLinqToDataTable();
}
}
Run Code Online (Sandbox Code Playgroud) 我不得不承认,我只是计划难过......我有以下LINQ to SQL方法 - >
public static int GetLastInvoiceNumber(int empNumber)
{
using (var context = CmoDataContext.Create())
{
context.Log = Console.Out;
IQueryable<tblGreenSheet> tGreenSheet = context.GetTable<tblGreenSheet>();
return (tGreenSheet
.Where(gs => gs.InvoiceNumber.Substring(3, 4) == empNumber.ToString())
.Max(gs => Convert.ToInt32(gs.InvoiceNumber.Substring(7, gs.InvoiceNumber.Length)))
);
}
}
Run Code Online (Sandbox Code Playgroud)
这是基于同事编写的SQL查询来实现的,它实现了几乎相同的东西 - >
SELECT DISTINCT
SUBSTRING([InvoiceNumber], 1, 6) AS EmpNumber,
MAX(CAST(SUBSTRING([InvoiceNumber], 7, LEN([InvoiceNumber])) AS INT)) AS MaxInc
FROM [CMO].[dbo].[tblGreenSheet]
WHERE SUBSTRING([InvoiceNumber], 3, 4) = '1119' --EmployeeNumber
GROUP BY SUBSTRING([InvoiceNumber], 1, 6)
Run Code Online (Sandbox Code Playgroud)
但是,当我检查时生成的SQL context.Log = Console.Out是 - >
SELECT …Run Code Online (Sandbox Code Playgroud) c# ×7
.net ×2
linq-to-sql ×2
oop ×2
sql ×2
winforms ×2
.net-4.0 ×1
arrays ×1
asp.net-mvc ×1
javascript ×1
jquery ×1
linq ×1
ms-office ×1
ms-word ×1
properties ×1