|
Theres 101 data access layers out there, go do some googling and you'll find plenty including tutorials on how to make your own.
|
|
|
|
|
eggie5 wrote: I somehow need to get the names of deriving class' public fields. Reflection?
Yep, reflection would be the way to get the data. Custom attributes would come in handy too:
class Person
{
[Column("AgeColumn")]
public int Age;
}
Where TableFieldName is a custom attribute. Those may come in handy to get the corresponding table or column for a class or field.
As the other poster noted, there are a lot of data access layers out there that do this. In the upcoming .NET 3.5, you'll have built-in support for this in the form of LINQ (language integrated query), and it's extension of LINQ-to-SQL and other databases. See Scott Guthrie's blog post on LINQ to SQL[^] for more info.
|
|
|
|
|
I have a class: classA
classA starts a new thread: threadA
threadA fires an event.
My classB has a listener to this event.
When threadA fires the event I want to run a method in classB.
However, myMethod() will run it on the threadA thread and I want it to run on the main thread (like the rest of the classB class, and the variables etc)!
I'm using the compact framework
Do you know of a way to switch to the main thread to execute the method? Will I need to create an invoker? This seems more for windows forms..
I hope I’ve explained it well enough and you can make some sense of it!
any help is greatly appreciated.
|
|
|
|
|
Best way to do this is have your main thread watch a queue of functions, e.g. delegates to execute. When your background thread needs to have a function execute on the main thread, enqueue that function into the main thread queue of pending actions. When a new function is enqueued, have the main thread execute it.
This is essentially how calling control.Invoke and .BeginInvoke works in WindowsForms: you're essentially posting a message to the UI thread message queue, telling it to execute some delegate.
|
|
|
|
|
Hey guys,
I have been toying around with the idea of writing a website creation program geared to novice computer users. I have googled it and I can't find anything helpful in regards to how to structure the program or writing code generation. Can anybody point me in the right direction?
may your code be error free
|
|
|
|
|
There are 3 parts:
1. Input
2. Processing
3. Output
Seeing you have some form of input and you desire some form of output, the implement step 2. 90% of applications use this 'data transformation'. There is no magic involved.
|
|
|
|
|
Hi,
This is just off the top of my head as I haven't done any web work for years, but depending on exactly how much functionality you wish to offer and what code you wish to generate, you should look at .NET CodeDOM for code generation and the use of XSLT with XML. XSLT can convert XML to HTML or XHTML markup, but it can also be used to generate C#, javascript or any other language from XML. If you got the users to make selections via your UI then stored these as XML you could easily generate code thus. I'm sorry not to provide more detail, but I think this is at least the right direction.
Regards,
Toby
|
|
|
|
|
Thanks a million Toby for the heads up. That's the most info i've got so far. I'll definitly take a look at it and if you have anymore info, I'd be happy to hear it!
Thanks again,
Richard
may your code be error free
|
|
|
|
|
how can I convert a char arrayto a string?
i used method ToString() but it dosn'twork .
|
|
|
|
|
One of the constructors for a string takes a char[].
|
|
|
|
|
you can try:
string s = new string(mycharArray);
|
|
|
|
|
For generic purpose type converting there's a static class "Convert". There you have a "ToString([param])" method
Visit my blog at http://dotnetforeveryone.blogspot.com/
|
|
|
|
|
I think the best way to do that is to use a generic list
List<char> chars = new List<char>();
chars.Add('t');
Console.WriteLine(chars[0].ToString());
Lester
http://www.lestersconyers.com
|
|
|
|
|
lsconyer wrote: the best way
The best way to fail a code review maybe!
|
|
|
|
|
That's a bad idea, lester. First of all, it only returns the first character as a string, not the whole character array. Secondly, adding the chars to a list does nothing to help converting the whole thing to a string.
|
|
|
|
|
Did you look at the earlier replies at all ?
your "best way" is plain wrong, it does not address the problem, it needs at least .NET 2.0,
it creates more than one object, and it is in no way better than a simple string constructor.
Life is study.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/AllLanguages/General
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
My, my, my. I didn't know programmers could be so sassy. Excuse me experts. I guess I didn't understand the problem. Please forgive me.
Lester
http://www.lestersconyers.com
|
|
|
|
|
lsconyer wrote: Please forgive me
No problem.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
We don't mean to be sassy, just wanted to correct a wrong answer. No harm meant.
|
|
|
|
|
string str = new string(char[] value);
Toby Russell
|
|
|
|
|
Dear all,
i would like to know is it possible to use function with optional parameter or is there any better way of doing so.
thnk you
imaran khan
|
|
|
|
|
There are no "default" parameters like there are in C++.
However, you can achieve the same thing with a simple overload.
public void myFunction(int requiredArg){
myFunction(requiredArg, false);
}
public void myFunction(int requiredArg, bool optionalArg){
}
|
|
|
|
|
thank for reply
Actually i have one to fifteen parameter and fuction must take one parameter and rest depending on user choice program will pass.
how to do that
please help
thanks
imaran khan
|
|
|
|
|
Could you explain it a bit more please?
You could cast all the parameters to an object[] and then cast them back inside of the function, giving default values to the ones that the user didn't specify.
|
|
|
|
|
thnks for reply.
let me explaine the scenario. there is 15 field say suppose
customer , category ,subcategory etc ..
User select category or subcategory or customer or any thing
depending on selection ,value from corresponding master is populated. now i select values from dropdownlistbox and pass to fuction.
Now my problem is user may select only customer or category or subcategory. may select combination or all.
please guide.
thanks
imran khan
|
|
|
|