我有类"Estimation",这个类有一个属性"EstimationItems"(类型是IList)
public class EstimationItem
{
public virtual int Id { get; set; }
public virtual Product Product { get; set; }
public virtual int Quantity { get; set; }
public virtual decimal Price { get; set; }
}
public class Product
{
public virtual int Id { get; set; }
public virtual string Code { get; set; }
public virtual string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
当我有一个"Estimation"实例时,我想知道"EstimationItems"是否包含代码为"MyCode"的产品.
我认为在一次采访中问这个有点荒谬.但如果面试官问......需要回答.
深入解释:
问候,
我想找到用户所在的组列表.我从http://www.codeproject.com/KB/system/everythingInAD.aspx尝试了几个解决方案 但没有结果.
这段代码给我一个"真实",表示LDAP正在运行:
public static bool Exists(string objectPath)
{
bool found = false;
if (DirectoryEntry.Exists("LDAP://" + objectPath))
found = true;
return found;
}
Run Code Online (Sandbox Code Playgroud)
谢谢,
更新1:
public ArrayList Groups(string userDn, bool recursive)
{
ArrayList groupMemberships = new ArrayList();
return AttributeValuesMultiString("memberOf", "LDAP-Server",
groupMemberships, recursive);
}
public ArrayList AttributeValuesMultiString(string attributeName,
string objectDn, ArrayList valuesCollection, bool recursive)
{
DirectoryEntry ent = new DirectoryEntry(objectDn);
PropertyValueCollection ValueCollection = ent.Properties[attributeName];
IEnumerator en = ValueCollection.GetEnumerator();
while (en.MoveNext())
{
if (en.Current != null)
{
if (!valuesCollection.Contains(en.Current.ToString()))
{ …Run Code Online (Sandbox Code Playgroud) 我有一张桌子,这张桌子有3列.在每列中,都有一张类似于图片的表格.我做了一个生成表的方法,这个方法在参数中接收一个列表并在其上循环以将addCell添加到表中
我想一条线有一个而不是5列...... 1 + 1(colspan of 4).当我做一个colspan时,第一个被合并,我想合并4最后并保持第一个.
我怎样才能做到这一点 ?
谢谢,

我有一个只有这样的字符串成员的类:
public class MyClass
{
public string MyProp1 { get; set; }
public string MyProp2 { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我创建了一个实例:
Var myClass = new MyClass();
Run Code Online (Sandbox Code Playgroud)
稍后在代码中,我想知道所有成员(MyProp1和MyProp2)是否为空或空.我知道我可以使用if当然但在我的实际代码中有比2更多的属性.
有没有办法做到这一点 ?
谢谢,
我有一个函数,这个函数在参数中接收一个字符串.此变量的内容是HTML代码.我想知道该类的HTML元素数量.myClass
function MyTest(myData){
//get how many element with .myClass are in myData
}
Run Code Online (Sandbox Code Playgroud)
谢谢,
我有一个按钮:
<asp:Button
runat="server"
ID="btNew"
OnClick="ButtonNew_Click"
Text="New" />
Run Code Online (Sandbox Code Playgroud)
我有 OnClick 方法:
protected void ButtonNew_Click(object sender, EventArgs e)
{
}
Run Code Online (Sandbox Code Playgroud)
在同一页面 (.aspx) 上,我有一个 JavaScript 函数:
function MyCheck()
{
// Return true or false
}
Run Code Online (Sandbox Code Playgroud)
我希望当我单击按钮时执行 JavaScript 函数 ( MyCheck())。如果为真,则执行ButtonNew_Click()。如果为 false,则不执行ButtonNew_Click()。
有任何想法吗?
我有两个列表(ListA和ListB),这些列表的类型相同PersonInfo,Login字段是唯一键。
public class PersonInfo
{
public string Login { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public int Age { get; set; }
public bool Active { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我想比较这两个列表:
我想得到一个ListA不可用的项目列表ListB
对于两个列表中可用的项目,我想从ListA(Login字段是唯一键)获取两个列表之间存在差异的项目的列表。
示例:如果对于中的Login“MyLogin” ListA, 的值FirstName与 中的值不匹配ListB。带有“MyLogin”的项目Login必须是结果列表的一部分。
示例:如果特定登录Age之间的ListA和ListB不同,则该项目必须是结果的一部分
谢谢。
有没有办法将匿名类型"强制转换"为特定的界面?我知道我可以创建一个实现此接口的类,但我不需要这个类,我必须返回一个接口.
我需要没有第三方库的解决方案
谢谢,
var result =
(from a in context.TABLE1
join b in context.TABLE2 on a.Table2Id equals b.Id
select new
{
Table1Field1 = a.Field1,
Table2Field1 = b.Field1,
....
}).ToList<IMyClass>();
public interface IMyClass
{
string Table1Field1 { get; set; }
string Table1Field2 { get; set; }
string Table2Field1 { get; set; }
}
Run Code Online (Sandbox Code Playgroud) 在我的测试中,我将数据定义为数据a List<IUser>.
我想设置一个moq方法GetList,这个方法接收一个boolas参数.我想回复IUser列表哪里IsValid是真的.
我试过这个:
Mock<IUsers> mockUserRepository = new Mock<IUsers>();
mockUserRepository.Setup(mr => mr.GetList(It.IsAny<bool>()))
.Returns((bool i) => _users.Select(x => x.IsValid == i));
Run Code Online (Sandbox Code Playgroud)
但我得到这个错误: cannot convert List<bool> to List<IUser>
class User : IUser
{
public bool IsValid { get; set; }
}
interface IUser
{
bool IsValid { get; set; }
}
interface IUsers
{
List<IUser> GetList(bool isActive);
}
Run Code Online (Sandbox Code Playgroud) c# ×7
.net ×3
linq ×2
asp.net ×1
itextsharp ×1
jquery ×1
mocking ×1
moq ×1
nhibernate ×1
reporting ×1