質問

I am tryin to use EF4 with CSLA. im in CSLA for like 2 weeks and now I am trying to interact with my database. What I amhere for is simple step by step advice like:

  1. Create DataPortal
  2. A method example
  3. ...

Or maybe just a Website with good tutorial. Fact is, I don't even know how to start because I am not used to entities and the DataPortal.

Here is some example code:

public void ExecuteDelete(object obj)
{
    try
    {
        // Delete from Database
        db.Farbe.Remove(db.Farbe.Find(SelectedIndex.FarbauswahlNr));
        db.SaveChanges();
    }
    catch (Exception e)
    {
        MessageBox.Show(e.ToString());
    }
    // call Refresh
    ListeAktualisieren();
}
役に立ちましたか?

解決

You might want to check their Faq: http://www.lhotka.net/cslanet/faq/

Also the community is pretty helpful: http://forums.lhotka.net/forums/5.aspx

Finally, there are samples here: http://lhotka.net/files/csla40/CslaSamples-4.3.12.zip

It depends on what you're trying to do; Csla supports several sterotypes of objects (read only root, read only list, commands, etc.) which dictate which subclass you should inherit. For example, if you are doing a command type behavior, you'd inherit CommandBase and override the DataPortal_Execute method, which is where your posted code would mostly live. I'm not sure what your Refersh method does, but it might be something that would happen on the client and not the database and so would not be in the DataPortal_Execute override.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top