Linq to entities

Linq to entities

Old forum URL: forums.lhotka.net/forums/t/5911.aspx


koen@skn.be posted on Monday, December 01, 2008

Hello,

i am new to CSLA and i am looking for some samples :

1) CSLA with linq to entities for example the CustomerList.Fetch.

2) An object factory in a seperate assembly, so my business objects are completely seperated from my database(s), so my application can run on different databases just by using a different DAL.

 

Can anyone help me find these samples ?

Thx

JoeFallon1 replied on Monday, December 01, 2008

If you order the preview of the ebook then #2 should be answered there.

Rocky shows #1 with L2S in the book not L2E.

Joe

RockfordLhotka replied on Monday, December 01, 2008

Fortunately, at least in terms of design, the use of L2E is the same as L2S. There are some minor coding differences (because EF is a little more picky and complex than L2S), but the techniques used in the book for L2S are the same techniques for EF and/or L2E.

koen@skn.be replied on Tuesday, December 02, 2008

I downloaded the book and found this on p.18-6, isn't the fetch method missing in this class ?

What does this Fetch method return ?

Assuming the factory object is in a separate assembly, here’s an example of a

factory class with a Fetch() method:

public class CustomerFactory : ObjectFactory

{

using (var ctx = ConnectionManager<SqlConnection>.GetManager("MyDb"))

{

using (var cm = ctx.Connection.CreateCommand())

{

cm.CommandType = CommandTypes.Text;

cm.CommandText = "SELECT Id, Name FROM Customer WHERE id=@id";

using (var dr = new SafeDataReader(cm.ExecuteReader()))

{

dr.Read();

var result = (BusinessLibrary.CustomerEdit)Activator.CreateInstance(

typeof(BusinessLibrary.CustomerEdit), true);

MarkNew(result);

result.LoadData(dr);

return result;

}

}

}

}

Copyright (c) Marimer LLC