Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ._C#_Asp.net_Linq_Linq To Sql - Fatal编程技术网

C# .

C# .,c#,asp.net,linq,linq-to-sql,C#,Asp.net,Linq,Linq To Sql,只需使用ArrayList public static ArrayList GetMembersItems(string ProjectGuid) { ArrayList items = new ArrayList(); items.AddRange(yourVariable .Where(p => p.yourProperty == something)

只需使用ArrayList

    public static ArrayList GetMembersItems(string ProjectGuid)
    {
        ArrayList items = new ArrayList(); 
        items.AddRange(yourVariable 
                        .Where(p => p.yourProperty == something)
                        .ToList());
        return items;
    }

他使用的是3.5,不能使用动态。在.NET3.5中,没有动态。我认为你不应该删除动态。只需提及“如果您使用的是.NET4.0,您可以使用动态类型链接”之类的内容。请注意,我担心的是返回类型感谢百万好友。我使用了“selectnewmycustomclass”而不是“selectnew”,而不是通过结果集再次迭代
ctx = new CoreDBDataContext();
var exitPointDetails = from ma in ctx.MapAssets
                       join ep in ctx.ExitPoints
                           on ma.MapAssetID equals ep.MapAssetID
                       where ma.ProjectID == iProjectID
                       select Tuple.Create(ma, ep);
return exitPointDetails.ToList();
string lastName AnonType.GetValue<string>("LastName");
int age AnonType.GetValue<int>("Age");
private static AnonymousType ProvisionAgent(string name, int department)
        {
            return AnonymousType.Create(new
            {
                Name = name,
                Department = department
            });
        }

        private List<AnonymousType> CreateAnonAgentList()
        {
            var anonAgents = new List<AnonymousType>();

            //  Dave and Cal are in Department 13
            anonAgents.Add(AnonymousType.Create(CreateAgentAnonType("Dan Jacobs", 13, 44)));
            anonAgents.Add(AnonymousType.Create(CreateAgentAnonType("Calvin Jones", 13, 60)));

            //  Leasing = Dept 45
            anonAgents.Add(AnonymousType.Create(CreateAgentAnonType("Stanley Schmidt", 45, 36)));
            anonAgents.Add(AnonymousType.Create(CreateAgentAnonType("Jeff Piper", 45, 32)));
            anonAgents.Add(AnonymousType.Create(CreateAgentAnonType("Stewart Blum", 45, 41)));
            anonAgents.Add(AnonymousType.Create(CreateAgentAnonType("Stuart Green", 45, 38)));

            //  HR = Dept 21
            anonAgents.Add(AnonymousType.Create(CreateAgentAnonType("Brian Perth", 21, 25)));
            anonAgents.Add(AnonymousType.Create(CreateAgentAnonType("Katherine McDonnel", 21, 23)));

            return anonAgents;
        }
object ReturnAnonymous()  
{  
  return new { Name="Faisal", City="Chakwal" };  
}  

// Application entry-point  
void Main()  
{  

  object o = ReturnAnonymous();  

   // This call to 'Cast' method converts first parameter (object) to the  
   // same type as the type of second parameter - which is in this case   
   // anonymous type with 'Name' and 'City' properties  
   var typed = Cast(o, new { Name="", City="" });  
   Console.WriteLine("Name={0}, City={1}", typed.Name, typed.City);  
 }  

 // Cast method - thanks to type inference when calling methods it   
 // is possible to cast object to type without knowing the type name  
 T Cast<T>(object obj, T type)  
 {  
   return (T)obj;  
 }  
List<object> lstAnonymousTypes = GetExitPointDetailsByProjectID(1);

foreach(object o in lstAnonymousTypes)
{
   //Change it accordingly
   var typed = Cast(o, new { new MapAssets() , new ExitPoints() }); 
}
    public static ArrayList GetMembersItems(string ProjectGuid)
    {
        ArrayList items = new ArrayList(); 
        items.AddRange(yourVariable 
                        .Where(p => p.yourProperty == something)
                        .ToList());
        return items;
    }