I'm quit new in c# and linq and I need to fill an ObjectDataSource (in vb.net) with code using a class in another project (in .c#).
I tried doing these things:
1. Add the reference
2. "Imports Project2" in the code behind page.
3. Fill in the load event:
Dim ObjectClass1 As New Class1(ConnectionString)
myODS.TypeName = "ObjectClass1"
myODS.SelectMethod = "GetData"
myODS.SelectParameters("Filter1Name") = New Parameter("Filter1Name", DbType.String, "xxx")
The class in the other project looks like this:
public class Class1 { public string ConnectionString { get; } public Class1(string connectionString) { ConnectionString = connectionString; } public IQueryable<MyObject> GetData(string Filter1Name) { using (MyObjectDataContext dataContext = new MyObjectDataContext(ConnectionString)) { var Result = dataContext.MyObject.Where(x => x.FILTER_1== Filter1Name).Select(x => new MyObject { Field1 = x.FIELD_1, Field2 = x.FIELD_2 }); return Result; } } }
And this is the error I get: ObjectDataSource 'myODS' could not find a non-generic method 'GetData' that has parameters: Filter1Name
What this error means? Is it possible to do what I'm trying to do?
It means it can't find a method on your class called
GetInfo()Looking at your class1 definition, you probably meant to make itGetDataDim ObjectClass1 As New Class1(ConnectionString)