Will this C# picece of code acts same as an SQL query?
hello group,
In a code (following) it seems some data are retreived from a MS SQL 2008 database. Does this mean there no need for any query or stored procedure in the database physically?
I'm new to this type of coding...
Will this get the data?
Thanks!
var context = ObjectContextHelper.CurrentObjectContext; var query = from c in context.Countries orderby c.DisplayOrder, c.Name where (showHidden || c.Published) && c.Allowed select c; var countryCollection = query.ToList();
Do you mean this piece of code will do the job of retreiving data from table?
akohan
ASKER
Elimesika,
Thanks for your help. I have added a new method to an existing code (I just followed other methods to see how they work) my method now works but doesn't return any data off the database. so do you mean I need to do something with Linq?
var query = from c in context.Countries
orderby c.DisplayOrder, c.Name
where (showHidden || c.Published) && c.Allowed
select c;
That looks like a query, does the code work? I'm not quite sure what you're asking.
akohan
ASKER
yes it is a query but I'm new to this kind of query since I'm not famliar with linq
now, what I'm trying to say is that there is a methodA() uses this and gets the information so I have followed its step but mine doesn't bring back any data.
what could be missed in my work?
Thanks for the information you shared, OK, I found out that I had forgotten to call the function in the caller !!! BUT now I'm getting an error as following:
Mapping and metadata information could not be found for EntityType 'Test-Solutions.BusinessLogic.Directory.CustomerType'
1) My database model (TestModel.edmx) was not updated. However, after this step still there still was the same error message
2)The name of entity or table was not as the name in database... so I had to fix the naming but step 1 was requred anyway.
Thanks to all for your feedback.
akohan
ASKER
Sorry for the delay ... been out of town for a month with no access to internet!